Error is the real something happen from exception. Exception is the way to catch the error. For example when you get the variable let say String str, we got Null Pointer. The error is because our variable has NULL value and it catch with Exception: "Null Pointer Exception".
Programming errors fall into three categories:
1-Compilation Errors,
2-Run-time Errors,
3-Logical Error
Compilation Errors:-
Compilation errors, also known as compiler errors, are errors that prevent your program from running
Run Time Errors:-
Run-time errors are errors that occur while your program runs.
Logic Errors:-
Logic errors are errors that prevent your program from doing what you intended it to do.
and exception are the run time error!
In simple words error can not be handled , but exceptions can be handled, with the help of try and catch.
try{
Conditions here...
}catch(Throwable ex){
ex.print trace();
}
Like this you can catch an exception
0 Comment(s)