Here's my question: I want to time how long the program takes to sort an array. I try to print the result afterward, but it prints out a 0. Here's my main method:
public static void main(String[] args) {
for ( int b = 0; b < array1.length; b++) {
int n = (int)(Integer.MAX_VALUE * Math.random());
array1[b] = n;
array2[b] = n;
}//end of for loop
long startTime = System.currentTimeMillis();
insertionSort(array1);
long runTime = System.currentTimeMillis() - startTime;
System.out.println("The runtime of the sorting is "+ runTime);
}//end of main
And here's my output:
The runtime of the sorting is 0
Thanks in advance!