Avoiding Null Pointer Exceptions.
Hi:
This might sound like a newbie question.
In a funtion that returns an object of another class, if the required parameters are all rights (i.e no 'problems' ) the funtion works well. But in case, I have to return something (but not 'throwable' an exception) I return a 'null'. And this obviously is not a very good thing.
Please let me know what I can return such that the accepting method doesnt throw NPE.
Cheers,
Mack.
public TorsionBeamStressDistributor GetTBSDfromID(String tbsdid){
try{
TorsionBeamStressDistributor tbsdid_focal =new TorsionBeamStressDistributor(tbsdid);
return BootStrap.getStressPadManager().getBeamStructureManager().find(tbsdid_focal);//long as all is well.
}
catch(Exception e){
System.out.println(e.getMessage());
}
returnnull;// I want to have a better alternative than this... returning null.
}

