{"id":25524390,"date":"2022-05-16T15:30:43","date_gmt":"2022-05-16T10:00:43","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25524390"},"modified":"2022-11-20T08:39:42","modified_gmt":"2022-11-20T03:09:42","slug":"exceptions-and-errors-in-java-all-you-need-to-know","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/","title":{"rendered":"Exceptions and Errors In Java- All You Need To Know"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69ea1c67840c8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69ea1c67840c8\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#The_concept_of_exception_handling\" >The concept of exception handling<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#Java_Exceptions_Hierarchy\" >Java Exceptions Hierarchy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#Types_of_exceptions_in_Java\" >Types of exceptions in Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#What_is_an_Error_in_Java\" >What is an Error in Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#Difference_between_Exception_and_Error\" >Difference between Exception and Error<\/a><\/li><\/ul><\/nav><\/div>\n<p>Java exception is one of the most important concepts of Java programming. If you&#8217;re a beginner, you should get a basic understanding of how Java exception works and how you can utilize it in your programming. Java Exception is a simple mechanism for handling runtime errors. If we try to understand &#8220;exception&#8221; in general, it relates to errors that take place while executing a program. Exception handling is also used in C# programming language. So, if you get an idea of how exception handling works in Java, you can easily use it in other programming languages as well.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_concept_of_exception_handling\"><\/span><strong>The concept of exception handling<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>At its core, a program is a set of instructions. To run properly, it should not have any logical, runtime, or syntax errors. Whenever a program encounters any runtime error, an exception is raised. The exception object is then thrown by the program, which is handled by the exception handler. Since everything in Java is an object, that means exceptions created by programs are also objects. These objects contain information about the type of exception, as well as additional data that needs to be transmitted.<\/p>\n<p>Example:<\/p>\n<p>#FileNotFoundException<\/p>\n<p>try {<br \/>\nnfile = new File(&#8220;abc.txt&#8221;);<br \/>\nnfile.readLine;<br \/>\nnfile.write(&#8220;another item for the list&#8221;);<br \/>\nnfile.close();<br \/>\n} catch (FileNotFoundException fnfe) {<br \/>\nsystem.out.write(&#8220;File not found, Please make sure that the file is present in the location or you are entering the correct file name&#8221;);<br \/>\n}<\/p>\n<p>The above is a try-catch code that tries to create a new file. If the creation fails or the file is not present at the current location, the code in the try should throw an exception object. The\u00a0FileNotFoundException\u00a0handles the exception object. The coder can either print a statement or perform an action that handles the situation correctly.<\/p>\n<p>Some examples of when exceptions can happen are:<\/p>\n<ul>\n<li>Dividing by zero<\/li>\n<li>Accessing Array element with an out of bounds index.<\/li>\n<li>Passing an incorrect argument to a method.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Java_Exceptions_Hierarchy\"><\/span><strong>Java Exceptions Hierarchy<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The class at the top of the exception class hierarchy is the Throwable class, which is a direct subclass of the Object class. Throwable has two direct subclasses &#8211; Exception and Error.<\/p>\n<p>The Exception class is used for exception conditions that the application may need to handle. Examples of exceptions include\u00a0IllegalArgumentException,\u00a0ClassNotFoundException\u00a0and\u00a0NullPointerException.<\/p>\n<p>The Error class is used to indicate a more serious problem in the architecture and should not be handled in the application code. Examples of errors include\u00a0InternalError,\u00a0OutOfMemoryError\u00a0and\u00a0AssertionError.<\/p>\n<p>Exceptions are further subdivided into checked (compile-time) and unchecked (run-time) exceptions. All subclasses of\u00a0RuntimeException\u00a0are unchecked exceptions, whereas all subclasses of Exception besides\u00a0RuntimeException\u00a0are checked exceptions.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Types_of_exceptions_in_Java\"><\/span><strong>Types of exceptions in Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><strong>Checked Exceptions<\/strong><\/h3>\n<p>Exceptions that can occur at compile-time are called checked exceptions since they need to be explicitly checked and handled in code. Classes that directly inherit Throwable &#8211; except\u00a0RuntimeException\u00a0and Error &#8211; are checked exceptions e.g.\u00a0IOException,\u00a0InterruptedException\u00a0etc.<\/p>\n<p>Here is an example of a method that handles a checked exception:<\/p>\n<p>public void writeToFile() {try (BufferedWriter bw = new BufferedWriter(new FileWriter(&#8220;myFile.txt&#8221;))) {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 bw.write(&#8220;Test&#8221;);\u00a0\u00a0\u00a0 } catch (IOException ioe) {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ioe.printStackTrace();\u00a0\u00a0\u00a0 }}<\/p>\n<p>In this example, both statements within the try block (the instantiation of the\u00a0BufferedWriter\u00a0object and writing to file using the object) can throw\u00a0IOException, which is a checked exception and therefore needs to be handled either by the method or its caller. In the example,\u00a0IOException\u00a0is handled within the method and the exception stack trace is printed to the console.<\/p>\n<p>Furthermore, the\u00a0BufferedWriter\u00a0object is a resource, which should be closed when it is no longer needed and closing it can throw an\u00a0IOException\u00a0as well. In such cases where closing resources themselves can throw exceptions, using a try-with-resources block is best practice since this takes care of the closing of resources automatically. The example shown earlier uses try-with-resources for exactly this reason.<\/p>\n<h3><strong>Unchecked Exceptions<\/strong><\/h3>\n<p>Unchecked exceptions can be thrown &#8220;at any time&#8221; (i.e. run-time). Therefore, methods don&#8217;t have to explicitly catch or throw unchecked exceptions. Classes that inherit\u00a0RuntimeException\u00a0are unchecked exceptions e.g.\u00a0ArithmeticException,\u00a0NullPointerException.<\/p>\n<p>Here is an example of a method that throws an unchecked exception (NullPointerException) which is not handled in code:<\/p>\n<p>public void writeToFile() {try (BufferedWriter bw = null) {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 bw.write(&#8220;Test&#8221;);\u00a0\u00a0\u00a0 } catch (IOException ioe) {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ioe.printStackTrace();\u00a0\u00a0\u00a0 }}<\/p>\n<p>When the above method is called, a NullPointerException is thrown because the BufferedWriter object is null:<\/p>\n<p>Exception in thread &#8220;main&#8221; java.lang.NullPointerException\u00a0\u00a0 \u00a0at IOExceptionExample.writeToFile(IOExceptionExample.java:10)\u00a0\u00a0 \u00a0at IOExceptionExample.main(IOExceptionExample.java:17)<\/p>\n<p>As mentioned, since\u00a0NullPointerException\u00a0is an unchecked exception, it did not need to be handled in code &#8211; only the checked exception (IOException) was handled.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_is_an_Error_in_Java\"><\/span><strong>What is an Error in Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In\u00a0Java, an error is a subclass of Throwable that tells that something serious problem is existing and a reasonable Java application should not try to catch that error. Generally, it has been noticed that most of the occurring errors are abnormal conditions and cannot be resolved by normal conditions. As these errors are abnormal conditions and should not occur, thus, error and its subclass are referred to as\u00a0<strong>Unchecked Exceptions<\/strong>. In Java, we have the concept of errors as well as exceptions. Thus there exist several differences between an exception and an error. Errors cannot be solved by any handling techniques, whereas we can solve exceptions using some logic implementations. So, when an error occurs, it causes termination of the program as errors cannot try to catch.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Error Name<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>AbstractMethodError<\/strong><\/td>\n<td>When a Java application tries to invoke an abstract method.<\/td>\n<\/tr>\n<tr>\n<td><strong>Error<\/strong><\/td>\n<td>Indicating a serious but uncatchable error is thrown. This type of error is a subclass of Throwable.<\/td>\n<\/tr>\n<tr>\n<td><strong>AssertionError<\/strong><\/td>\n<td>To indicate that an assertion has failed.<\/td>\n<\/tr>\n<tr>\n<td><strong>ClassCircularityError<\/strong><\/td>\n<td>While initializing a class, a circularity is detected.<\/td>\n<\/tr>\n<tr>\n<td><strong>IllegalAccessError<\/strong><\/td>\n<td>A Java application attempts either to access or modify a field or maybe invoking a method to which it does not have access.<\/td>\n<\/tr>\n<tr>\n<td><strong>ClassFormatError<\/strong><\/td>\n<td>When JVM attempts to read a class file and find that the file is malformed or cannot be interpreted as a class file.<\/td>\n<\/tr>\n<tr>\n<td><strong>InstantiationError<\/strong><\/td>\n<td>In case an application is trying to use the Java new construct for instantiating an abstract class or an interface.<\/td>\n<\/tr>\n<tr>\n<td><strong>ExceptionInInitializerError<\/strong><\/td>\n<td>Signals that tell an unexpected exception have occurred in a static initializer.<\/td>\n<\/tr>\n<tr>\n<td><strong>InternalError<\/strong><\/td>\n<td>Indicating the occurrence of an unexpected internal error in the JVM.<\/td>\n<\/tr>\n<tr>\n<td><strong>IncompatibleClassChangeError<\/strong><\/td>\n<td>When an incompatible class change has occurred to some class of definition.<\/td>\n<\/tr>\n<tr>\n<td><strong>LinkageError<\/strong><\/td>\n<td>Its subclass indicates that a class has some dependency on another data.<\/td>\n<\/tr>\n<tr>\n<td><strong>NoSuchFieldError<\/strong><\/td>\n<td>In case an application tries to access or modify a specified field of an object, and after it, that object no longer has this field.<\/td>\n<\/tr>\n<tr>\n<td><strong>OutOfMemoryError<\/strong><\/td>\n<td>In case JVM cannot allocate an object as it is out of memory, such error is thrown that says no more memory could be made available by the GC.<\/td>\n<\/tr>\n<tr>\n<td><strong>NoClassDefFoundError<\/strong><\/td>\n<td>If a class loader instance or JVM, try to load in the class definition and not found any class definition of the class.<\/td>\n<\/tr>\n<tr>\n<td><strong>ThreadDeath<\/strong><\/td>\n<td>Its instance is thrown in the victim thread when in thread class, the stop method with zero arguments is invoked.<\/td>\n<\/tr>\n<tr>\n<td><strong>NoSuchMethodError<\/strong><\/td>\n<td>In case an application tries to call a specified method of a class that can be either static or instance, and that class no longer holds that method definition.<\/td>\n<\/tr>\n<tr>\n<td><strong>StackOverflowError<\/strong><\/td>\n<td>When a stack overflow occurs in an application because it has recursed too deeply.<\/td>\n<\/tr>\n<tr>\n<td><strong>UnsatisfiedLinkError<\/strong><\/td>\n<td>In case JVM is unable to find an appropriate native language for a native method definition.<\/td>\n<\/tr>\n<tr>\n<td><strong>VirtualMachineError<\/strong><\/td>\n<td>Indicate that the JVM is broken or has run out of resources, essential for continuing operating.<\/td>\n<\/tr>\n<tr>\n<td><strong>UnsupportedClassVersionError<\/strong><\/td>\n<td>When the JVM attempts to read a class file and get to know that the major &amp; minor version numbers in the file are unsupportable.<\/td>\n<\/tr>\n<tr>\n<td><strong>UnknownError<\/strong><\/td>\n<td>In case a serious exception that is unknown has occurred in the JVM.<\/td>\n<\/tr>\n<tr>\n<td><strong>VerifyError<\/strong><\/td>\n<td>When it is found that a class file that is well-formed although contains some sort of internal inconsistency or security problem by the verifier.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Difference_between_Exception_and_Error\"><\/span><strong>Difference between Exception and Error<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<table>\n<tbody>\n<tr>\n<td><strong>Exception<\/strong><\/td>\n<td><strong>Error<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Can be handled<\/td>\n<td>Cannot be handled.<\/td>\n<\/tr>\n<tr>\n<td>Can be either checked type or unchecked type<\/td>\n<td>Errors are of unchecked type<\/td>\n<\/tr>\n<tr>\n<td>Thrown at runtime only, but the checked exceptions known by the compiler and the unchecked are not.<\/td>\n<td>Occurs at the runtime of the code and is not known to the compiler.<\/td>\n<\/tr>\n<tr>\n<td>They are defined in Java.lang.Exception package.<\/td>\n<td>They are defined in Java.lang.Error package<\/td>\n<\/tr>\n<tr>\n<td>Program implementation mistakes cause exceptions.<\/td>\n<td>Errors are mainly caused because of the environment of the program where it is executing.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25522670 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"Python and Machine Learning Rectangle\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<p><strong>Why is it important to choose Entri?<\/strong><\/p>\n<ul>\n<li>Excellent online platform for all the Competitive Exams.<\/li>\n<li>Provides updated materials created by the Entri Experts.<\/li>\n<li>Entri provides a best platform with full- length mock tests including previous year question papers.<\/li>\n<li>You can download the app for free and join the required classes.<\/li>\n<li>Entri wishes you all the best for your examinations and future endeavours.<\/li>\n<\/ul>\n<p><strong>\u201cYOU DON\u2019T HAVE TO BE GREAT TO START, BUT YOU HAVE TO START TO BE GREAT.\u201d<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java exception is one of the most important concepts of Java programming. If you&#8217;re a beginner, you should get a basic understanding of how Java exception works and how you can utilize it in your programming. Java Exception is a simple mechanism for handling runtime errors. If we try to understand &#8220;exception&#8221; in general, it [&hellip;]<\/p>\n","protected":false},"author":55,"featured_media":25524392,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1882],"tags":[],"class_list":["post-25524390","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-java-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exceptions and Errors In Java- All You Need To Know - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exceptions and Errors In Java- All You Need To Know - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Java exception is one of the most important concepts of Java programming. If you&#8217;re a beginner, you should get a basic understanding of how Java exception works and how you can utilize it in your programming. Java Exception is a simple mechanism for handling runtime errors. If we try to understand &#8220;exception&#8221; in general, it [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-16T10:00:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-20T03:09:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ayesha Surayya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayesha Surayya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\"},\"author\":{\"name\":\"Ayesha Surayya\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\"},\"headline\":\"Exceptions and Errors In Java- All You Need To Know\",\"datePublished\":\"2022-05-16T10:00:43+00:00\",\"dateModified\":\"2022-11-20T03:09:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\"},\"wordCount\":1524,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png\",\"articleSection\":[\"Articles\",\"Java Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\",\"url\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\",\"name\":\"Exceptions and Errors In Java- All You Need To Know - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png\",\"datePublished\":\"2022-05-16T10:00:43+00:00\",\"dateModified\":\"2022-11-20T03:09:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png\",\"width\":820,\"height\":615,\"caption\":\"Exceptions and Errors In Java- All You Need To Know\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Exceptions and Errors In Java- All You Need To Know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\",\"name\":\"Ayesha Surayya\",\"url\":\"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exceptions and Errors In Java- All You Need To Know - Entri Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/","og_locale":"en_US","og_type":"article","og_title":"Exceptions and Errors In Java- All You Need To Know - Entri Blog","og_description":"Java exception is one of the most important concepts of Java programming. If you&#8217;re a beginner, you should get a basic understanding of how Java exception works and how you can utilize it in your programming. Java Exception is a simple mechanism for handling runtime errors. If we try to understand &#8220;exception&#8221; in general, it [&hellip;]","og_url":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-05-16T10:00:43+00:00","article_modified_time":"2022-11-20T03:09:42+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png","type":"image\/png"}],"author":"Ayesha Surayya","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Ayesha Surayya","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/"},"author":{"name":"Ayesha Surayya","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097"},"headline":"Exceptions and Errors In Java- All You Need To Know","datePublished":"2022-05-16T10:00:43+00:00","dateModified":"2022-11-20T03:09:42+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/"},"wordCount":1524,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png","articleSection":["Articles","Java Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/","url":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/","name":"Exceptions and Errors In Java- All You Need To Know - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png","datePublished":"2022-05-16T10:00:43+00:00","dateModified":"2022-11-20T03:09:42+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Exceptions-and-Errors-In-Java-All-You-Need-To-Know.png","width":820,"height":615,"caption":"Exceptions and Errors In Java- All You Need To Know"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/exceptions-and-errors-in-java-all-you-need-to-know\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"Exceptions and Errors In Java- All You Need To Know"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097","name":"Ayesha Surayya","url":"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25524390"}],"version-history":[{"count":4,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524390\/revisions"}],"predecessor-version":[{"id":25547532,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524390\/revisions\/25547532"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25524392"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25524390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25524390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25524390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}