可能重复:
字符串到布尔转换的最佳性能
哪个被认为是更好的实践,更重要的是,它会给我带来更好的表现吗?
布尔构造函数的文档说:
* <p><b>Note: It is rarely appropriate to use this constructor.
* Unless a <i>new</i> instance is required, the static factory
* {@link #valueOf(boolean)} is generally a better choice. It is
* likely to yield significantly better space and time performance.</b>
valueOf
返回对常量值的引用,因此不会创建新对象。