java get last index of array

www.l‮uttua‬ri.com
java get last index of array
/**
 * @author lautturi.com
 * Java example: java get last index of array 
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		int[] numbers = {1,2,3,4,5};
		int last  = numbers[numbers.length-1];
		
		System.out.println("The last element of array is:"+last);

	}
}

output:

The last element of array is:5
Created Time:2017-09-06 22:23:59  Author:lautturi