Singly-linked list/Traversal: Difference between revisions
Content added Content deleted
(→Java) |
(→Java) |
||
Line 2: | Line 2: | ||
[[Category:Java]] |
[[Category:Java]] |
||
For Java.util.LinkedList<T> use a for each loop (from [[Loop Structures]]): |
For Java.util.LinkedList<T> use a for each loop (from [[Loop Structures]]): |
||
LinkedList<Type> list = new LinkedList<Type(); |
LinkedList<Type> list = new LinkedList<Type>(); |
||
for(Type i: list){ |
for(Type i: list){ |
Revision as of 04:47, 30 October 2007
Java
For Java.util.LinkedList<T> use a for each loop (from Loop Structures):
LinkedList<Type> list = new LinkedList<Type>(); for(Type i: list){ //each element will be in variable "i" System.out.println(i); }