0

what's wrong with my code

import java.util.Scanner; import java.util.ArrayList; public class Array { public static void main (String[] args) { Scanner in = new Scanner(System.in); ArrayList<Integer> numbers = new ArrayList<Integer>(); System.out.print("Enter no. of elements you want in array:"); while(in.hasNextInteger()) { numbers.add(in.hasNextInteger()); } System.out.println(numbers); } }

5th Nov 2020, 6:22 AM
Diether Absalon
Diether Absalon - avatar
1 Odpowiedź
+ 1
https://code.sololearn.com/c67XU7X1WgP1/?ref=app Method name is hasNextInt() gives Boolean value and nextInt() is input method . You write wrong method name....
5th Nov 2020, 6:32 AM
Prathvi
Prathvi - avatar