Scanner to int | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 3

Scanner to int

How do i convert scanner to int? I want user input in my method args but is says that scanner cant be converted to int. Please help.

28th Jun 2018, 8:51 PM
Terraria_master7 - avatar
3 ответов
+ 12
This code allocates an integer and scanner, followed by reading the integer from the scanner. int number; Scanner scan = new Scanner(; number = scan.nextInt();
28th Jun 2018, 9:23 PM
John Wells
John Wells - avatar
+ 5
you could also do this 👍 int input = new Scanner(;
29th Jun 2018, 8:29 AM
D_Stark - avatar
+ 1
or int num; Scanner sc = new Scanner( num = Integer.parseInt(;
29th Jun 2018, 8:49 AM
Siphelele Sanele Mndzebele
Siphelele Sanele Mndzebele - avatar