Very new to Java and am trying to create an array that has 5 integers and display them from first to last and last to first. What I have so far:
public class arrayex { public static void main (String[]args) { //create an array to hold 5 integers int [] array = new int [5]; int i=0; for(i=0;i<5;i++); System.out.println (array[i]); } }
Here is the error message I am getting. not sure why.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at arrayex.main(arrayex.java:19)