+ 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()); } }
5 odpowiedzi
+ 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());
}
}
+ 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);
}
}
+ 2
I made program u can see in my profile
+ 2
Thank you very much to clear my doubt.
actually the error was the space between
System. in
+ 1
take input in some variable