Errors in my java

This is a personal project and i don’t know why this doesn’t work.
</
import java.util.Scanner;
public class Program
{
public static void main(String args) {
System.out.println(“test”);
Scanner age = new Scanner(System.in);
System.out.println(age.nextInt());
if(age < 12){
System.out.println("you are in ");
} else {
System.out.println(“Too young”);
}

}

}

age is of type Scanner:

 Scanner age = new Scanner(System.in);

which won’t go well when attempting to do a comparison.

you get the integer here:

System.out.println(age.nextInt());

but on this line, age is still an instance of Scanner. Its not an integer. You don’t store the integer anywhere and you are also not using it in your if condition

thanks i will be back if i cant get it to work.

what would i do to verify the age @stetim94

in your condition:

if(age < 12){

age is an instance of scanner, you should retrieve the integer input from the scanner and use it in the condition of if

is there another way to recive user input

why would you want to go solve it in a different way instead of simply solving the problem you are facing?

im new to java and have no clue how to do what your saying

but you understand that you use Scanner to get input:

Scanner age = new Scanner(System.in);

then to get the integer from this object you need:

age.nextInt()

once you have this integer, you can use it in the comparison:

int ageNumber = age.nextInt();
System.out.println(ageNumber);
if (ageNumber < 12)

its not that difficult.

actually, doing something like:

Scanner scannerInput = new Scanner(System.in);
int age = scannerInput.nextInt();

would make more sense, but hopefully you get the idea

import java.util.Scanner;
public class Program
{
public static void main(String args) {
Scanner age = new Scanner(System.in);
int ageNumber = age.nextInt();
System.out.println(ageNumber);
if (ageNumber > 12){
System.out.println(“you are in”);
string
} else{
System.out.println(“No acess”);
}
}
}