I'm trying to run this program but I do not know where to put "main". It seems like the program does not have errors but whenever I run it I get error: Error: Main method not found in class Lab2, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
`
import java.util.Arrays;
public class Lab2 {
// compute sorting
int [] sortingArrayOne = new int[10000]; // array one
int [] sortingArrayTwo = new int[10000]; // array two
public void randomNumbers() {
for (int i = 0; i < sortingArrayOne.length; i++) {
sortingArrayOne[i]=(int)(Integer.MAX_VALUE * Math.random()); // filling array one with random integer
sortingArrayTwo[i]=sortingArrayOne[1]; // same random numbers in both arrays
long startTimeArrayOne=System.currentTimeMillis(); // run time of array one
selectionSort(sortingArrayOne); // sorting array one using selection sort
long runTimeArrayOne=System.currentTimeMillis() - startTimeArrayOne; // run time of selection sort
long startTimeArrayTwo = System.currentTimeMillis(); // computing time for array two
Arrays.sort(sortingArrayTwo); // sorting array two
long runTimeArrayTwo=System.currentTimeMillis() - startTimeArrayTwo; // time to run
System.out.println("Selection sort time:" + runTimeArrayOne); // printing sort time
System.out.println("Arrays sort time:" + runTimeArrayTwo); // printing array sort time
}}
static void selectionSort(int[] A) {
// Sort A into increasing order, using selection sort
for (int lastPlace = A.length-1; lastPlace > 0; lastPlace--) {
// Find the largest item among A[0], A[1], ...,
// A[lastPlace], and move it into position lastPlace
// by swapping it with the number that is currently
// in position lastPlace.
int maxLoc = 0; // Location of largest item seen so far.
for (int j = 1; j <= lastPlace; j++) {
if (A[j] > A[maxLoc]) {
// Since A[j] is bigger than the maximum we’ve seen
// so far, j is the new location of the maximum value
// we’ve seen so far.
maxLoc = j;
}
}
int temp = A[maxLoc]; // Swap largest item with A[lastPlace].
A[max`Loc] = A[lastPlace];
A[lastPlace] = temp;
} // end of for loop
}}
I tried writing main for this pice: `long startTimeArrayOne=System.currentTimeMillis(); // run time of array one selectionSort(sortingArrayOne); // sorting array one using selection sort long runTimeArrayOne=System.currentTimeMillis() - startTimeArrayOne; // run time of selection sort
long startTimeArrayTwo = System.currentTimeMillis(); // computing time for array two Arrays.sort(sortingArrayTwo); // sorting array two long runTimeArrayTwo=System.currentTimeMillis() - startTimeArrayTwo; // time to run
System.out.println("Selection sort time:" + runTimeArrayOne); // printing sort time System.out.println("Arrays sort time:" + runTimeArrayTwo); // printing array sort time }}`
but then I am getting different errors...