Created
January 27, 2016 19:03
-
-
Save sax1johno/9f400a178f35ac24cbc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorld{ | |
public static void main(String []args){ | |
System.out.println("Hello World"); | |
Float x = 5; | |
try { | |
Float.parseInt(x); | |
} catch (ParseException e) { | |
// Required to catch this because of throws statement in method declaraction | |
System.out.println("Parse exception"); | |
} catch (InvalidFormatException e) { | |
// Required to catch this because of throws statement in method declaraction | |
System.out.println("Invalid format exception"); | |
} catch (SomeOtherException e) { | |
// Not required to catch this but you probably should. | |
System.out.println("This is another exception here"); | |
} catch (Exception e) { | |
System.out.println("Some other exception occurred"); | |
// Don't do this if you can help it - it swallows errors and makes code more buggy. | |
} | |
} | |
} | |
public static Integer parseInt throws InvalidFormatException, ParseException { | |
throw SomeOtherException("This can be thrown inside the method at any time."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment