Given that an ArrayList named a whose elements are of type Integer has been declared, assign the value -1 to the last element in a.

Given that an ArrayList named a whose elements are of type Integer has been declared, assign the value -1 to the last element in a.

LANGUAGE: JAVA

CHALLENGE:

Given that an ArrayList named a whose elements are of type Integer has been declared, assign the value -1 to the last element in a.

SOLUTION:

a.set(a.size()-1,-1);

Add comment