Assume that the ArrayList arr has been declared. Write a statement that assigns the next to last element of the array to the variable x, which has already been declared.
LANGUAGE: JAVA
CHALLENGE:
Assume that the ArrayList arr has been declared. Write a statement that assigns the next to last element of the array to the variable x, which has already been declared.
SOLUTION:
x = arr.get(arr.size() - 2);