My question is how to store the generated list of this array
.
On the line numeros[i] = ...
If I understand correctly, you already do this, keep in the array
what is typed in the entry that can be read as a double
.
As a suggestion, you can use Scanner.html#hasNextDouble
before to check if the typed content can be interpreted as a value double
:
Scanner kb = new Scanner (System.in);
double [] numeros = new double [10];
for (int i = 0; i < numeros.length; i++) {
System.out.println("Digite o próximo número: ");
if(kb.hasNextDouble()) {
numeros[i] = kb.nextDouble();
}
}
To display the contents of array
, you can do so:
System.out.println(Arrays.toString(numeros));
Or so:
for (double numero: numeros) {
System.out.println(numero);
}
See DEMO
And what is the doubt?
– user28595
My question is how to store the generated list of this array.
– cambine
It would be interesting to edit the question, because it is not in the format of a.
– user28595
@cambine I edited your question, she’s a little confused, you can edit it or revert to previous state.
– stderr