+ 1

nextInt();

when i use this it throws noSuchElement exeption i imported java.util.scanner please help

29th Jun 2018, 6:22 AM
Terraria_master7
Terraria_master7 - avatar
4 Answers
+ 5
Terraria_master7 if your using multiple inputs remember that your scanner is looking for a new line containing either a string or a integer, when inputting make sure you use diffrent lines and that the input matchs the specified type as you cant use nextInt() for string this would thow an exception
29th Jun 2018, 8:12 AM
D_Stark
D_Stark - avatar
+ 2
i did
29th Jun 2018, 6:59 AM
Terraria_master7
Terraria_master7 - avatar
+ 1
you need to create Scanner Scanner sc = new Scanner(System.in); int number; number = sc.nextInt(); if i remember good
29th Jun 2018, 6:41 AM
Daniel (kabura)
Daniel (kabura) - avatar
29th Jun 2018, 7:12 AM
Daniel (kabura)
Daniel (kabura) - avatar