import java.util.*; class InvalidValueException extends Exception{ InvalidValueException(String S){ super(s); } } class Exception{ static void validate(int value) throws IOException.InvalidValueException{ if(value<10){ throw new InvalidValueException("Invalid value"); } else{ System.out.println("This is valid integer"); } } public static void main(String[]args){ try{ validate(S); } catch(Exception m){ System.out.println("Exception occured"+m); } System.out.println("code after exception"); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter