I need to create an array using a constructor, add a method to print the array as a sequence and a method to fill the array with random numbers of the type double.
Here's what I've done so far:
import java.util.Random;
public class NumberList {
private static double[] anArray;
public static double[] list() {
return new double[10];
}
public static void print(){
System.out.println(String.join(" ", anArray);
}
public static double randomFill() {
return (new Random()).nextInt();
}
public static void main(String args[]) {
// TODO
}
}
I'm struggling to figure out how to fill the array with the random numbers I have generated in the randomFill method. Thanks!