//This code is designed to create and populate an array with
//Ten Integer values
Scanner in = new Scanner(System.in);
//Create the array
int [] intArray = new int [10];
//populating the array
for(int i =0; i<=10; i++){
System.out.print("Enter the elements: ");
intArray[i]= in.nextInt();
}
//Print the Values in the array
System.out.println(Arrays.toString(intArray));
}
}
Explanation:
The above code looks like it will run successfully and give desired output.
But a bug has been introduced on line 9. This will lead to an exception called ArrayIndexOutOfBoundsException.
The reason for this is since the array is of length 10, creating a for loop from 0-10 will amount to 11 values, and the attempt to access index 10 for the eleventh element will be illegal
One way to fix this bug is to change the for statement to start at 1.
I'm not too experienced with code including external memory, but i believe there was an error with the code mixing that either mixed lines of code up or got rid of code to save files onto your device. Try looking up code for the device, see if that helps at all.