5 ms·
Hate to point it out, but java booleans can only be true or false. Booleans (capital B) can be true, false or null.
by Phrodo_00 3y ago
Hate to point it out, but java booleans can only be true or false. Booleans (capital B) can be true, false or null.
- dfox 3y agoMethod that is declared as only ever returning bool can also raise any exception that is an instance of java.lang.RuntimeException (which includes NullPointerException) this somewhat bizzare design which combines unchecked and checked exceptions is a source of major discussions since at least late 90's and has much to do with the current concept of null-safety.
- hedora 3y agoYeah, but using a raw boolean or Boolean is not considered good practice. They’re up to at least four states now: null, None, Some(TRUE) and Some(FALSE) Of course, if you want more than that, you can have unboundedly many by invoking new Boolean(), which guarantees its return value is unique according to ==