Click here to watch in Youtube :
https://www.youtube.com/watch?v=3WfBUqHxqKE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Exception Handling |
/* * With out exception handling */ public class ExceptionHandlingDemo1 { public static void main(String[] args) { int intValue = 50; System.out.println("intValue = " + intValue); double doubleValue = 45.9; System.out.println("doubleValue = " + doubleValue); String str = null; System.out.println("str = " + str.toString()); float floatValue = 10.f; System.out.println("floatValue = " + floatValue); long longValue = 45000; System.out.println("longValue = " + longValue); } }
intValue = 50 doubleValue = 45.9 Exception in thread "main" java.lang.NullPointerException at ExceptionHandlingDemo1.main(ExceptionHandlingDemo1.java:16)
/* * With exception handling. */ public class ExceptionHandlingDemo2 { public static void main(String[] args) { int intValue = 50; System.out.println("intValue = " + intValue); double doubleValue = 45.9; System.out.println("doubleValue = " + doubleValue); try { String str = null; System.out.println("str = " + str.toString()); } catch(Exception exe) { System.out.println("String value is null"); } float floatValue = 10.f; System.out.println("floatValue = " + floatValue); long longValue = 45000; System.out.println("longValue = " + longValue); } }
intValue = 50 doubleValue = 45.9 String value is null floatValue = 10.0 longValue = 45000
https://sites.google.com/site/javaee4321/java/ExceptionDemo_Exception_handling_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ExceptionDemo_Exception_handling_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/c539eeaf4c6ff331d8e2aa2333826ea70c999093/BasicJava/ExceptionDemo_Exception_handling_App/?at=master
See also:
No comments:
Post a Comment