Here's my question: I'm coding a program, but the program throws an exception, and I don't know why or how to fix it. Here's the code:
public class ArraySortingTiming {
int i = 10;
int[] array1 = new int[i];
int[] array2 = new int[i];
for (int a = 0; a < array1.length() ||a < array2.length(); a ) {
int n = (int)(Integer.MAX_VALUE * Math.random());
array1[a] = n;
array2[a] = n;
}
public static void main(String[] args) {
ArraySortingTiming a = new ArraySortingTiming();
}
}
And here's the exception message:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "(", ; expected
Syntax error on token ")", ; expected
at programmingassignments.ArraySortingTiming.main(ArraySortingTiming.java:14)
I tried changing each array definition to int[] array1 = new int[10]; eliminating the i constant, but it still doesn't work.
Thank you in advance!
CodePudding user response:
You need to move your for loop block inside your main function.