How I do create an array of size 256 with sorted random numbers in the main method? I want to create an array that randomly generates numbers between 1-256, the size would be 256 as well which means it would have 256 numbers in the array and they're sorted. My code only returns me zero?
public class Array {
public static void main(String args[])
{
double[] randomarray = new double[256];
for(int i = 0; i<randomarray.length;i++)
randomarray[i] = Math.random();
for (int i = 0; i<randomarray.length;i++)
System.out.println(randomarray[i]);
}
}
Aucun commentaire:
Enregistrer un commentaire