int[] myArray = new int[] {1,2,3,4,5,6,7,8,9,10};
for(int number : myArray) {
System.out.println(myArray[number]);
}
and this is the output:
2
3
4
5
6
7
8
9
10
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at javaPractice.selfAssignArrays.main(selfAssignArrays.java:10)
what's wrong with it?
myArray[number]do? What is each value ofnumberat each iteration? What is the base index of an array?