+ 1
What is wrong in this code? Plz help.
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); if (myVar==5){ System.out.println("too young");} else{ System.out.println(myVar.nextLine()); } } }
2 Respuestas
+ 2
thanks. it is working
+ 1
here you using Scanner so first you need to import Scanner....the edited code is as shown below...
import java.util.Scanner;
public class A {
public static void main(String[ ] args) {
Scanner myVar = new Scanner(System.in);
int age=myVar.nextInt();
if(age==5){
System.out.println("too young");}
else{
System.out.println(myVar.nextLine());
}
}
}