Check out example codes for "find last element in array in java". It will help you in understanding the concepts better.

Code Example 1

firstNum = numbers.get(0);
lastNum = numbers.get(numbers.size() - 1);

Code Example 2

firstNum = numbers[0];
lastNum = numbers[numbers.length-1];

Learn ReactJs, React Native from akashmittal.com