0
I need to generate 100000 numbers, store them in an array and sort them using the Bubblesort algorithm, is appearing the error "Exception in thread "main" java.lang.Error: Unresolved Compilation problem:
at testaSort.main(testaSort.java:8)"
Code below:
import java.util.*;
import java.util.Random;
import javax.swing.*;
public class testaSort {
public static void main(String[] args)
{
int i;
long inicio;
long fim;
double tempo;
int[] vetor = new int [100000];
int intervaloInicial = 0;
int intervaloFinal = 100000;
for (i=0 ; i < vetor.length; i++)
{
vetor [i] = getRandomNumberRange(intervaloInicial , intervaloFinal);
System.out.println(vetor[i]);}
}
private static int getRandomNumberRange(int min, int max)
{
Random r = new Random();
return r.ints (min,(max+1)).limit(1).findFirst().getAsInt();
}
//BubbleSort
System.out.println("--Bubblesort--");
inicio = System.currentTimeMillis();
Sort.bubbleSort(vetor);
fim = System.currentTimeMillis();
System.out.printf("%.3f ms%n", (fim - inicio) / 1000d);
}
}