/**
* @author lautturi.com
* Java example: java get last element of array
*/
import java.util.*;
import java.util.Map.Entry;
public class Lautturi {
public static void main(String[] args) {
int[] numbers = { 11,4,2,7,55,16,12,8,13,38 };
int firstElement = numbers[0];
int lastElement = numbers[numbers.length-1];
System.out.println("The first element of array is:"+firstElement);
System.out.println("The last element of array is:"+lastElement);
}
}
output:
The first element of array is:11 The last element of array is:38