Documentation for the constructor new Boolean(boolean value) in Java states:
Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory
valueOf(boolean)is generally a better choice. It is likely to yield significantly better space and time performance.
If so, why is this constructor public and not deprecated? Is there ever a good reason to use this constructor instead of Boolean.valueOf()?
valueOf()only got added in Java 1.4, so it would appear that the constructors exist for backwards compatibility.This ticket explains the reasons for not deprecating the constructors:
I can’t think of a realistic scenario where using
Booleanconstructors would be the best way to do something useful.