Answered by : grieving-grebe-7pud8y2ox3rq
arrayName[arrayName.length() - 1];
Source : | Last Update : Thu, 12 Mar 20
Answered by : stupid-seal-lkprxu0vos8u
firstNum = numbers[0];
lastNum = numbers[numbers.length-1];
Source : https://stackoverflow.com/questions/39860739/how-to-get-first-and-last-element-in-an-array-in-java | Last Update : Fri, 15 May 20
Answered by : sobhanbera
int[] arr = new int[5]; //length of the array is 5
int val = arr[arr.length - 1]; //here variable val stores the last element of arr
Source : | Last Update : Fri, 14 Aug 20
Answered by : oldfashioned-oyster-gra8ma3ppewg
int [] numbers = {1, 2, 3, 4, 5};
firstElement = numbers[0];
lastElement = numbers[numbers.length-1];
Source : | Last Update : Sat, 20 Mar 21
Answered by : crazy-constrictor-tw3nhlaule7k
int last = list.get(list.size() - 1);
Source : | Last Update : Wed, 23 Sep 20
Answered by : tender-teira-dw5o0fsiikce
firstNum = numbers.get(0);
lastNum = numbers.get(numbers.size() - 1);
Source : https://stackoverflow.com/questions/39860739/how-to-get-first-and-last-element-in-an-array-in-java/39860831 | Last Update : Sat, 05 Sep 20
Answered by : kritik-modi
int a[]={1,2,3};
int last = a[a.length-1];
Source : | Last Update : Sat, 27 Aug 22
Answered by : yn
// GIVE FIRST NUMBER AND LAST NUMBER
firstNum = numbers[0];
lastNum = numbers[numbers.length-1];
Source : | Last Update : Sun, 16 Aug 20