1.
Q1: Put the code in the appropriate order so that an
ArrayList
of integers will store multiples of 5 (from 100 down to 0) in reverse order.
ArrayList
of integers will store multiples of 5 (from 100 down to 0) in reverse order.
ArrayList
? (Select all that are appropriate)
FavoriteAuthors
NineHundred
RibbonColors
TopTen
ClassroomHeights
ArrayList
named numbers
. Which of the following code snippets would be best for this task?
public void addOne(ArrayList<Integer> numbers) {
for (int i = 0; i < numbers.size(); i++) {
numbers.set(i, numbers.get(i) + 1);
}
}
public void addOne(ArrayList<Integer> numbers) {
for (int num : numbers) {
num++;
}
}
public void addOne(ArrayList<Integer> numbers) {
for (int num : numbers) {
numbers.set(num, num + 1);
}
}
num
as both index and value.public void addOne(ArrayList<Integer> numbers) {
for (int i = 0; i < numbers.size(); i++) {
numbers.set(i, i + 1);
}
}