java input console scanner code example
Example 1: User input (scanner)
Scanner scanner = new Scanner(System.in);
System.out.println("What's your name?");
String name = scanner.nextLine();
System.out.println("What's your year of birth?");
int yearOfBirth = scanner.nextInt();
Example 2: User input (scanner)
String line = scanner.nextLine();
int age = Integer.parseInt(line); // Exception-t