0
Please explain me the mistake I made
import java.util.Scanner; public class myclass{ public static void main(String[] args){ System.out.println("Please Enter you Age"); Scanner age = new Scanner(System.in); if (age<18){ System.out.println("You are UNDERAGE"); } else { System.out.println("WELCOME"); } } } actually, I also have a doubt that I got the user input(his age) is it stored as an int in the variable age, because in the print statement then why are we adding the nextint() function??
2 Respuestas
+ 2
age is a Scanner, not an int. Scanner's purpose is to get input from the user. You have to declare an int. Then assign it with age.nextInt();
https://www.sololearn.com/learn/Java/2220/
0
Thank You So Much