+ 3

Can you please help me rectify the error in this java program.

I'm new to Java... so please say me if I committed any silly mistake in the following program. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner var=new Scanner (System. in); System.out.println("Enter some input :"); System .out.println("the entered input is :" + var.nextLine()); } }

12th Jan 2018, 1:35 PM
Subikesh
Subikesh - avatar
5 ответов
+ 2
this worked well 👍 import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner var=new Scanner(System.in); System.out.println("hi. enter something"); // int variable=var.nextInt(); System .out.println("the entered is :"+ var.nextInt()); } }
12th Jan 2018, 2:17 PM
Subikesh
Subikesh - avatar
+ 2
thanks for replying. but even after modification, it should similar errors. Actually it prints the first line and then shows error in input line. import java.util.Scanner; public class Program { public static void main(String[] args) { int variable; Scanner var=new Scanner (System. in); System.out.println("hi. enter something"); variable=var.nextInt(); System .out.println("the entered is :"+ variable); } }
12th Jan 2018, 1:58 PM
Subikesh
Subikesh - avatar
+ 2
I made program u can see in my profile
12th Jan 2018, 2:08 PM
Arpit Srivastava
Arpit Srivastava - avatar
+ 2
Thank you very much to clear my doubt. actually the error was the space between System. in
12th Jan 2018, 2:15 PM
Subikesh
Subikesh - avatar
+ 1
take input in some variable
12th Jan 2018, 1:50 PM
Arpit Srivastava
Arpit Srivastava - avatar