1import java.util.InputMismatchException;
2import java.util.Scanner;
3
4public class Number {
5
6 public static void main(String[] args) {
7
8 int yourNumber;
9
10 while(true) {
11
12 // to read inputs from user
13 Scanner scan = new Scanner(System.in);
14
15 try {
16 System.out.print("ayy bruh enter you age : ");
17
18 // throws InputMismatchException if it's not a number
19 yourNumber = scan.nextInt();
20
21 scan.close();
22 break;
23 }catch(InputMismatchException notNumber) { // << catch the exception and print the error message
24 System.err.println("huh I can understand numbers,"
25 + "ENTER A NUMBER !");
26 }
27 }
28
29 // print the result :))
30 System.out.printf("so your age is %d, ..AWESOME !! :))", yourNumber);
31
32 }
33
34}
35