Ice
Legacy Member
eniac zei:Point stands: hoe ga je weten waar de NPE zit? Die regel dient specifiek daarvoor.
Omdat je een error krijgt in de zin van: "UndefinedObject does not understand method3" ... ow juist, tis java ...
Als je NPE hebt ga je wrsch toch ff debuggen, dus whats the problem?
dan nog ff over multiple returns:
Code:
double getPayAmount() {
double result;
if (_isDead) result = deadAmount();
else {
if (_isSeparated) result = separatedAmount();
else {
if (_isRetired) result = retiredAmount();
else result = normalPayAmount();
};
}
return result;
};
Code:
double getPayAmount() {
if (_isDead) return deadAmount();
if (_isSeparated) return separatedAmount();
if (_isRetired) return retiredAmount();
return normalPayAmount();
};


