{"id":2678,"date":"2017-11-25T19:16:32","date_gmt":"2017-11-25T19:16:32","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2678"},"modified":"2017-11-25T19:16:32","modified_gmt":"2017-11-25T19:16:32","slug":"how-to-handle-exception-using-try-and-catch-block-in-core-java","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-handle-exception-using-try-and-catch-block-in-core-java\/","title":{"rendered":"How to Handle Exception using Try and Catch Block in Core Java"},"content":{"rendered":"<p>In this tutorial how to handle Exception using Try and Catch Block in Core Java\u00a0 is shown.<\/p>\n<p>Code:<\/p>\n<p>ExceptionDemo.java<\/p>\n<p>class ExceptionDemo<br \/>\n{<br \/>\npublic static void main(String args[])<br \/>\n{<br \/>\nint a=0;<br \/>\nint b=5;<br \/>\nSystem.out.println(&#8220;Message1&#8221;);<br \/>\ntry<br \/>\n{<br \/>\nSystem.out.println(b\/a);<br \/>\n}<br \/>\ncatch(ArithmeticException ae)<br \/>\n{<br \/>\nSystem.out.println(ae.getMessage());<br \/>\n}<br \/>\ncatch(Exception e)<br \/>\n{<br \/>\nSystem.out.println(e.getMessage());<br \/>\n}<\/p>\n<p>System.out.println(&#8220;Message2&#8221;);<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/tFW0UNTUpWM\">https:\/\/youtu.be\/tFW0UNTUpWM<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to handle Exception using Try and Catch Block in Core Java\u00a0 is shown. Code: ExceptionDemo.java class ExceptionDemo { public static void main(String args) { int a=0; int b=5; System.out.println(&#8220;Message1&#8221;); try { System.out.println(b\/a); } catch(ArithmeticException ae) { System.out.println(ae.getMessage()); } catch(Exception e) { System.out.println(e.getMessage()); } System.out.println(&#8220;Message2&#8221;); } }<!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[156],"tags":[157,150,181,180],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2678"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2678"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2678\/revisions"}],"predecessor-version":[{"id":2680,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2678\/revisions\/2680"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}