How can i make my Exception to be recognised ny the program i can see the catch but when i want the user to enter a string the inturn enters a number how do i do that?
importjava.util.InputMismatchException;importjava.util.Scanner;publicclass ExceptionExample{publicstaticvoid main(String[] args){System.out.println("Please enter a number");
Scanner sc =new Scanner(System.in);int num;try{
num = sc.nextInt();}catch(InputMismatchException n){System.out.println("Exception: Number required");}finally{System.out.println("Finally Block is always Executed");}}}