Skip to content

Instantly share code, notes, and snippets.

@maf946
Created November 30, 2022 14:41
Show Gist options
  • Save maf946/be17ef34ba4b7dd82e69da9389470be6 to your computer and use it in GitHub Desktop.
Save maf946/be17ef34ba4b7dd82e69da9389470be6 to your computer and use it in GitHub Desktop.
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