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
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
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); }