How to convert Scanner to double in java?

-1

I am developing a software, in which at one point the system should get a value informed by the user using the class Scanner and insert it into an array and then return an array with the values entered by the user, but I can not do Scanner conversion to double. Here's the line of code:

  double[] a = [Double.parseDouble(vlrus.nextDouble() + "")];
    
asked by anonymous 28.04.2018 / 00:24

1 answer

1

I see no reason for you to try to use an array here. I think what you want is just that:

double a = vlrus.nextDouble();

Then save the result to the array:

double[] b = new double[] {a};
    
28.04.2018 / 00:44