0
I want 2 scan age directly n place that in if statement. (Input of age have to place in age in if statement).can any1 correct me
import java.util.Scanner ; class Facebook { public static void main(String[]args){ Scanner variable = new Scanner (System.in) ; String age; age = variable.nextLine(); System.out.println("what is your age?"); int age = 30; if (age<16){ System.out.println("too young") ; } else { System.out.println("welcome") ; } } }
2 Réponses
+ 4
try out changing the type of age to int and successively the nextline function
0
thanks bro it works!