java-迭代链接列表 [英] java - iterating a linked list

查看:58
本文介绍了java-迭代链接列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Java中的链表上使用了for-each循环, 是否保证我会按顺序迭代元素 它们出现在列表中的位置?

if I use a for-each loop on a linked list in java, is it guaranteed that I will iterate on the elements in the order in which they appear in the list?

推荐答案

保证链接列表可以按顺序运行.

Linked list is guaranteed to act in sequential order.

文档

有序集合(也称为 顺序).该界面的用户 可以精确控制 列出插入的每个元素.这 用户可以通过他们的元素来访问元素 整数索引(在列表中的位置), 并在列表中搜索元素.

An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.

iterator() 以正确的顺序返回在此列表中的元素上的迭代器.

iterator() Returns an iterator over the elements in this list in proper sequence.

这篇关于java-迭代链接列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆