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
What value will be printed in the console after this series of commands? Assume that the ArrayList package has been imported.
ArrayList<Integer> array = new ArrayList<Integer>(); array.add(5); array.add(4); array.add(3); array.add(2); array.add(1); array.remove(1); array.set(0, 2); int num = array.get(1); System.out.println(num);
5
4
3
2
1