1ArrayList<String> namesList = new ArrayList<String>(Arrays.asList( "alex", "brian", "charles") );
2
3for(String name : namesList)
4{
5 System.out.println(name);
6}
7
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}