|
|
|
There are primarily 3 ways I can think of to traverse a java.util.List:
- Using a traditional
for loop;
- Using a simplified
for loop, or "foreach" statement in JDK 5 ;
- Using
java.util.Iterator
public static void traverse(List data) { System.out.println("Using simplified for loop/foreach:"); for(Object obj : data) { System.out.println(obj); }
System.out.println("Using for loop:"); for(int i = 0, n = data.size(); i < n; i++) { System.out.println(data.get(i)); }
System.out.println("Using Iterator:"); for(Iterator it = data.iterator(); it.hasNext();) { System.out.println(it.next()); } }
If you need any urgent assistance on Getting_OutofMemoryError_While_Executing_Code, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.
You can also subscribe to our newsletters on Getting_OutofMemoryError_While_Executing_Code, to receive updates on Getting_OutofMemoryError_While_Executing_Code,via email.Enter you email below:
Keyword Tags: Getting_OutofMemoryError_While_Executing_Code tutorial,Getting_OutofMemoryError_While_Executing_Code in java,Concepts of Getting_OutofMemoryError_While_Executing_Code,Java,J2EE,Interview Questions,Getting_OutofMemoryError_While_Executing_Code Examples
|
|
|