Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Which of the following is a correct way to print all elements in an ArrayList?
ArrayList
A:
for(int index = 0; index < array.size(); index++) { System.out.println(array.get(index)); }
B:
int counter = 0; while(counter <= array.size()) { counter++; System.out.println(array.get(counter)); }
C:
for (String element : array) { System.out.println(element); }
A and C only
All of the above