Below is my code
public class ExceptionHandling {
public static void main(String[] args) throws InputMismatchException{
Scanner sc = new Scanner(System.in);
int a = 0;
int b = 0;
try {
a = sc.nextInt();
b = sc.nextInt();
try {
int c = a / b;
System.out.println(b);
} catch (ArithmeticException e) {
System.out.println(e);
}
} catch (InputMismatchException e) {
System.out.println(e);
}
}
}
My main query from the above question is, when I am passing String as input then I am getting java.util.InputMismatchException
only.
But when I am passing 2147483648 as an input, it gives java.util.InputMismatchException: For input string: "2147483648"
as an output.
So can anyone tell me why I am getting For input string: "2147483648"
in that case?