Click here to watch in Youtube :
https://www.youtube.com/watch?v=xr9oIj-LbvM&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Exception handling (The catch blocks) |
public class CatchBlockDemo { public static void main(String[] args) { try { String str = null; // This line will throw NullPointerException System.out.println(str.length()); // This line will throw ArithmeticException int a = 5 / 0; } catch (ArithmeticException arithmeticException) { arithmeticException.printStackTrace(); } catch (NullPointerException nullPointerException) { nullPointerException.printStackTrace(); } System.out.println("Normal flow---"); } }
java.lang.NullPointerException at CatchBlockDemo.main(CatchBlockDemo.java:12) Normal flow---
https://sites.google.com/site/javaee4321/java/ExceptionDemo_The_catch_blocks_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ExceptionDemo_The_catch_blocks_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4babce59a384cb4ab41f12b03cd7d11227a4b186/BasicJava/ExceptionDemo_The_catch_blocks_App/?at=master
See also:
No comments:
Post a Comment