Exceptions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Exceptions

Can anyone explain to me what exceptions are? I really don't get it.

30th Jun 2019, 4:45 PM
Pasqalle Soeters
4 Answers
+ 2
See also this code by LukArToDo: https://code.sololearn.com/cE5BpKwo33DN/?ref=app
30th Jun 2019, 5:17 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Exceptions are errors/problems: Some examples: String str = null; System.out.println(str.length()); -> an empty String has no length() int x = 3; int y = 0; System.out.println(x/y); -> dividing by zero Having a Scanner scan: int x = scan.nextInt(); If you don't enter an integer you will get an error message. If you want to open a file which does not exist... With exception handling you can catch this exceptions and decide what to do. Your program will not just crash.
30th Jun 2019, 5:12 PM
Denise Roßberg
Denise Roßberg - avatar
0
Exceptions are just errors in your code
16th Oct 2020, 10:22 PM
Vuk Ovuka
Vuk Ovuka - avatar