xxxxxxxxxx
System.out.print(Primes1.get(Primes1.size() - 1) + " ");
xxxxxxxxxx
var my_array = /* some array here */;
var last_element = my_array[my_array.length - 1];
xxxxxxxxxx
let arr = ['a', 'b', 'c']
arr.slice(-1)[0] // returns last element in an array
xxxxxxxxxx
var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last
xxxxxxxxxx
var Cars = ["Volvo", "Mazda", "Lamborghini", "Maserati"];
//We can get the total number of elements like this.
var hmCars = Cars.pop();
//hmCars is now Maserati
console.log(hmCars)