0
How to read more than one numbers in one variable?
10 Answers
+ 1
You can put only one value to a variable. If you want to add multiple values to a variable, you can use array.
0
Variable or array?
0
Bibek Oli can i get array in scanner?
0
King Esteem đłđŹ Array
0
Please post the code you're trying to debug
0
1. Scan for the number of element to store in array, and store it in a variable;
2. Make a while loop to scan for an input, the iterator must be = to number of element, on every loop decrement the iterator by one, and make a conditional break statement when iterator is i-1;
0
King Esteem đłđŹ it shows int cannot be converted to int[]
0
Go and learn about casting in Java
0
Maybe u can try using an ArrayList:
Scanner input = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 1; i <= [NUMBER OF INTEGERS THAT YOU NEED]; i++)
{
list.add(input.nextInt());
}