A small gem I found the other day:
String value = ...boolean booleanValue = Boolean.valueOf(value.toLowerCase()).booleanValue();
A lot of useless stuff:
- toLowerCase is useless because the Boolean class is using equalsIgnoreCase.
- booleanValue is unnecessary because of automatic unboxing.
- Boolean.valueOf creates a useless temporary Boolean object.
boolean booleanValue = Boolean.parseBoolean(value);
And this works even if value is null.