There is a better way to access elements of an array by using looping construct .



class ArrayExample {
public static void main(String[] args) {

int[] age = new int[5];

...