Singly-linked list/Traversal: Difference between revisions
Content added Content deleted
No edit summary |
(→Java) |
||
Line 5: | Line 5: | ||
== Java == |
== Java == |
||
[[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>(); |
||
Revision as of 05:01, 30 October 2007
Singly-linked list/Traversal
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Traverse from the beginning of a singly-linked list to the end.
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); }