I have an work for school, I need to make array using int type numbers. I already assigned every value. If i try to run it, it shows that there is - Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20.
if (K==0) {
Random r = new Random();
for (i = 0; i < 20; i++)
A[i] = r.nextInt() * 100 - 50;
}
else {
for (i=0; i < 20; i++) { // It shows that problem is somewhere in
A[i] = A[i + 1] + K; // these 2 lines.
}
System.out.println("A:");
for (i = 0; i < 20; i++)