Assume that the array 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 array 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[arr.length - 2];