+ 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()); } } }

12th Feb 2017, 3:45 AM
sal sal
sal sal - avatar
2 Respuestas
+ 2
thanks. it is working
12th Feb 2017, 4:39 AM
sal sal
sal sal - avatar
+ 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()); } } }
12th Feb 2017, 4:25 AM
Chandan Kumar Y S
Chandan Kumar Y S - avatar