Sun Oct 21, 2012 12:54 pm
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String ar1[] = { "car", "pen", "house", "person", "ball" };
List stringList = new ArrayList();
for (String object : ar1) {
stringList.add(object);
}
Iterator stringsIterator = stringList.iterator();
System.out.println("Iteration of the strings list");
while (stringsIterator.hasNext()) {
System.out.print(stringsIterator.next() + "\t");
}
}
}
Iteration of the strings list
car pen house person ball
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.