Created
March 29, 2025 11:41
-
-
Save sanskarbhusal/3528157a2d6573407a64579740a2ef01 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 ExceptionExample { | |
public static void main(String args[]) { | |
try { | |
int x = 4; | |
int y = 0; | |
int result = x / y; | |
System.out.println(x + "Divided by " + y + "is: " + result); | |
} catch (Exception e) { | |
System.out.println("Division error!"); | |
} finally { | |
System.out.println("Final words, thank you!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment