In Java exception handling, throw keyword is used to explicitly throw an exception from a method or constructor. And throws keyword is used declare the list of exceptions which may be thrown by that method or constructor. 1. Java throw keyword 1.1. Syntax To throw an exception from a method or constructor, use throw keyword […]
Java try catch finally blocks helps in writing the application code which may throw exceptions in runtime and gives us chance to recover from the exception.
Learn the difference between checked vs unchecked exceptions in Java, with simple explanations and examples. Learn Java exception handling best practices.
This post is in continuation to exploring little known features of java. In previous post, I have covered “Instances of same class can access private members of each other” and Some very surprising usage of class sun.misc.Unsafe. In this post, I am discussing about a little known feature of initializes blocks. Initializers can be used […]
Java NullPointerException is an unchecked exception and extends RuntimeException. NullPointerException doesn’t force us to use catch block to handle it. This exception is very much like a nightmare for most of java developer community. They usually pop up when we least expect them. I have also spent a lot of precious time while looking for […]
In this Java tutorial, learn about asynchronous and synchronous exceptions in Java. Learn how they are different with checked and unchecked exceptions. 1. Asynchronous and synchronous exceptions Normally Java differentiate the exceptions in two categories on basis of “timing” when they are discovered. These categories are checked and unchecked exceptions. Similarly, on the basis of […]
We have been using handling java custom exceptions in our code for almost every industry standard application. Usual approach is to create some custom exception classes extending the base