Use of list, add elements and iterate
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class ListImplementation {
public ListImplementation() {
super();
}
public static void main(String args[]){
List<String> list = new ArrayList<String> ();
list.add(“Train”);
list.add(“Car”);
list.add(“Bike”);
Iterator<String> itr = list.iterator();
while(itr.hasNext()){
String i = itr.next();
System.out.println(i);
}
}
}