java user input

java user input scanner

#java #input #scanner

import java.util.scanner;

public class main {

public static void main(string[] args) {

scanner scanner = new scanner(system.in);

system.out.println("what is your name? ");
string name = scanner.nextline();

system.out.println("how old are you? ");
int age = scanner.nextint();
scanner.nextline();

system.out.println("what is your favorite food?");
string food = scanner.nextline();

system.out.println("hello "+name);
system.out.println("you are "+age+" years old");
system.out.println("you like "+food);

}
}

java user input