Error handling. exception එකක් පැන්නම terminate වෙන්න නොදී alternative actions ගන්න තමයි තියෙන්නේ.
*wouldn't call myself as an expert though*
SomeClass obj = getObj();
obj.executeSomething();
SomeClass getObj(){
return null;
}
huka
SomeClass obj = getObj();
try{
obj.executeSomething();
}catch(NullPointerException e){
e.printStacktrace();
}
finally{
sout("here!")
}
stacktrace
here!