take the keySet () method of HashMap for example:
public Set<K> keySet() {
Set<K> ks = keySet;
if (ks == null) {
ks = new KeySet();
keySet = ks;
}
return ks;
}
Wouldn"t it be more concise to write in the following form?
public Set<K> keySet() {
if(keySet == null) {
keySet = new KeySet();
}
return keySet;
}
public Set<K> keySet() {
return keySet == null ? (keyset = new KeySet()) : keySet;
}
does the author have any other intentions?