Created
November 30, 2022 14:41
-
-
Save maf946/be17ef34ba4b7dd82e69da9389470be6 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 Main | |
{ | |
public static void exceptionThrower() throws Exception { | |
throw new Exception("Something bad happened"); | |
} | |
public static void main(String[] args) | |
{ | |
try | |
{ | |
exceptionThrower(); | |
System.out.println("Try block"); | |
} | |
catch (Exception e) | |
{ | |
String errorMsg = e. getMessage(); | |
System.out.println(errorMsg); | |
System.out.println("Catch block"); | |
} | |
finally | |
{ | |
System.out.println("Finally block"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment