Use below code.
Scanner sc = new Scanner(System.in);
int arraysize=sc.nextInt();
double[] doubleArray = new double[arraysize];
for(int i=0; i<arraysize; i++){
doubleArray[i] = sc.nextDouble();
}
0
solved Array size and elements by user input [closed]