Simply throw-catch
an Exception
such as proposed ArithmeticException
or create your own:
try {
if(num2 == 0){
throw new ArithmeticException();
}
} catch (ArithmeticException e) {
System.out.println("Please input another integer than zero");
}
solved 0 cant be divided using try and catch java [closed]