+ 2

what am I doing wrong

I would like the scanner to gather int data and then print it out but it's not working what am I doing wrong? ; ( 😓 public class Program { public static void main(String[] args) { Scanner n = New; Scanner(nextint()); System.out.println(n.Nextint()); } }

7th Jul 2016, 8:34 PM
Victor
Victor - avatar
4 Answers
+ 7
import java.util.Scanner public class Program { public static void main(String[] args) { Scanner n =new Scanner(System.in); System.out.println(n.nextInt()); } }
8th Jul 2016, 12:16 AM
Gustavo Cabrera
Gustavo Cabrera - avatar
+ 3
or you can use like below... import java.util.Scanner; public class Program{ public static void main(String[] args){ Scanner n; n = new Scanner(System.in); System.out.println(n.nextInt()); n.close(); } }
8th Jul 2016, 8:00 AM
S.J LEE
S.J LEE - avatar
+ 2
THANKS!!!!!
9th Jul 2016, 10:28 PM
Victor
Victor - avatar
0
public class Program { public static void main(String[]arts) { Scanner n = new Scanner(System.in); int x = n.nextInt(); System.out.println(x); } }
7th Jul 2016, 8:40 PM
Ravi Jain
Ravi Jain - avatar