BooleanvalueOfboolean
Boolean.valueOf(boolean) is a static method in the Java standard library class java.lang.Boolean. It returns a Boolean object representing the specified primitive boolean value.
When invoked, the method returns one of two cached objects: Boolean.TRUE if the argument is true, or
This behavior makes valueOf the preferred way to convert a primitive boolean to its wrapper type, especially
Because Boolean objects are immutable, the cached instances are safe to share across threads without synchronization
Related methods include Boolean.valueOf(String), which parses a string into a Boolean, typically returning true when the
In summary, Boolean.valueOf(boolean) provides an efficient, canonical way to obtain Boolean wrapper instances for primitive boolean