Today We Will Learn How to use Exception Handling in Java Tutorial. The Exception handling on of the powerful tool to handle run time error. So that usual flow of the application can be continued. The exception is an irregular condition in Java, an exception is an event that interrupts the normal flow of the program. It as the object which is thrown at runtime.
Exception handling is used to handle runtime Error such as IO, SQL, ClassNotFound etc. It is very important to handle runtime error, if you want to make an application, you should be used Exception Handling. Otherwise, you are facing the problem.
- File Handling in Java
- ArrayList in Java
- Java Programming for Beginners
- Java Database Connectivity
- Set Look and Feel
- Billing System Project in Java
Types of Exception in Java
Tested and Untested where error is reflected as untested Exception, but Sun-Micro System declares there are three types of Exception:
- Tested Exception
- Untested Exception
The programs that extend throwable class except for Runtime Exception, and Mistake are known as tested exceptions e.g. IO Exception, SQL Exception etc. Tested exceptions are tested at compile-time.
The programs that extend Runtime Exception are known as untested exceptions. Arithmetic Exception, Null Pointer Exception, and Array Index out Of Bounds Exception etc. Untested exceptions are not tested at compile-time fairly they are tested at runtime.
The error is gone e.g. Out Of Memory Error, Virtual Machine Error, Assertion Error etc.
Arithmetic Exception in Java
I will understand you different exception usage, First of All, we will understand Arithmetic Exception. If you divide any number by Zero, that’s very simple math formula Any Number / 0. You can’t divide Any Number by Zero. If you are run the program and divide any number by Zero. You can say Arithmetic Exception.
Null Pointer Exception in Java
If you declare variable like (string a) and you don’t assignment value like (string a=null). Then you performing any operation by the variable follows a Null Pointer Exception.
Number Format Exception in Java
If you declare and assign value String (string a=”Checking”) may follow a Number Format Exception. For Example, I have made string variable that has characters, change this variable value into digit Follows a Number Format Exception (int b=Integer.paraseInt(a)).
Array Index Out of Bounds Exception
If you make an Array like (int a=new int;) and you will insert a value (a=30;) out of array index. Then you can see Array Index out of Bounds Exception. That’s simple example. I hope you have understood as well about Exception Handling errors.
However, Exception Handling in Java provides us 05 Five keywords (try, catch, finally, throw, throws). You can use them and handle the run-time error. Furthermore, I have made the video tutorial, I have shared on below. You can see and follow them, I hope video tutorial is helpful and beneficial for you.
Exception Handling in Java Tutorial
Thanks for Watch Complete video, after watch this video tutorial, I hope you have understood as well, and you will learn it something new. Kindly, share my content on social networks, and subscribe my website social networks pages like Facebook, Google+, Twitter, YouTube and Email for post updates.
If you have any question / suggestion about this topic, comment or email me after received your email or comment, I will reply with your answer maximum 24 hours. Thanks Again for a visit, Read my Complete Article and Watch my Videos. Keep touch my website, I will share very soon application like Android Application very soon.