Possible Duplicate:
Why should a function have only one exit-point?
I heard that method must have ideally one (no more) return
statement. It is true?
For example what type of method is better?
//1
public Object getResult() {
Object result;
if (someValue != null) { **// NOT null checking**
// initializing result
}
return result;
}
// 2
public Object getResult() {
Object result;
if (someValue == null) { // **null checking**
return null;
}
// initializing result
return result;
}