1ArrayList<String> namesList = new ArrayList<String>(Arrays.asList( "alex", "brian", "charles") );
2
3for(String name : namesList)
4{
5 System.out.println(name);
6}
7
1Iterator itr=list.iterator();
2while(itr.hasNext()){
3 system.out.println(itr.next);
4}
1for (int i = 0; i < crunchifyList.size(); i++) {
2 System.out.println(crunchifyList.get(i));
3 }
1// will iterate through each index of the array list
2// using the size of the array list as the max.
3// (the last index is the size of the array list - 1)
4
5for (int i = 0; i < myArrayList.size(); i++) {
6
7 System.out.println(myArrayList.get(i));
8 // will print each index as it loops
9}
1Iterator itr=list.iterator();
2while(itr.hasNext)
3{
4 system.out.println(itr.next);
5}