so i have this method:
class A(){
private Boolean Flag;
public java.lang.Boolean getFlag()
{
return this.Flag;
}
public java.lang.Boolean setFlag(Boolean Flag)
{
this.Flag = Flag ;
}
}
classB(){
boolean navalFlag = fancyObj.getFlag()
form.setNavalFlag(navalFlag?"Y":"N";
}
database returns null and Flag
is set to null.
What is a foolproof way where I can 100% avoid NPEs? I know Boolean
to boolean
casting is not a guarantee as seen from here
Update:
stepping through the code, the NPE is thrown in fancyObj.getFlag()
...which doesn't make sense to me. i would expect the NPE thrown in .setNavalFlag....