get last element of array java

Java
echo end($array);arrayName[arrayName.length() - 1];firstNum = numbers[0];
lastNum = numbers[numbers.length-1];
Source

Also in Java: