In Java, Boolean
and boolean
represent different types:
boolean
is a primitive data type that holds one of two values:true
orfalse
. It is used for simple flag or conditional logic and does not support methods or object behavior.
Boolean
is a wrapper class for theboolean
primitive. It is part of thejava.lang
package and allowsboolean
values to be treated as objects. It can be used with collections and provides utility methods likeBoolean.parseBoolean()
.
Boolean
is used when an object representation is needed, while boolean
is for primitive operations.