...
Code Block | ||
---|---|---|
| ||
public boolean isProperName(Optional<String> os) { if (os.isPresent()) { String names[] = os.getorElse("").split(" "); ifreturn (names.length != 2) { ? false return false;: } return (isCapitalized(names[0]) && isCapitalized(names[1])); else { return false; } } |
The Optional
class contains methods that can be used to make programs shorter and more intuitive [Urma 2014].
...
Null Pointer Dereference [XYH] | |
CWE-476. NULL pointer dereference |
...