Can anyone explain exception handling in Java or any reference? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone explain exception handling in Java or any reference?

7th Oct 2020, 1:30 PM
RøhiT Singh
RøhiT Singh - avatar
2 Answers
+ 6
During the execution of a program if any unwanted or unexpected error comes that is called an exception. It means if anything happens wrong during the execution of a program and disrupts the normal flow of the program’s instructions is called an exception. Exceptions may occur for different reasons: If the user has entered the wrong data. Like user is trying to divide any value by 0 e.g. 5/0. If the user tries to open a file with an invalid name. If a user tries to access an array with a negative index value. If a user tries to print a page but the printer doesn’t find it. Real-life example: Let’s take an example of a courier company. If I am sending a gift to my friend but due to some reason the courier company is failed to deliver. That is called exception because this is an unexpected thing happened during normal delivery of our product. If a company handling these types of problem and send a notification to me. https://javagoal.com/exception-handling-in-java/
8th Oct 2020, 10:09 AM
Raina Dhankhar
Raina Dhankhar - avatar
7th Oct 2020, 1:35 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar