The problem here is this piece of code: myArray.length
. In Java, as in most other languages, Data structures are 0 based, so the last element has an index of structure.length - 1
(and the first being 0
). So in your case, you should change your loop as follows:
for(int counter=myArray.length - 1; counter >= 0;counter--){
System.out.println(myArray[counter]);
}