How to convert String
object to Boolean
object?
Try (depending on what result type you want):
Boolean boolean1 = Boolean.valueOf("true");
boolean boolean2 = Boolean.parseBoolean("true");
Advantage:
Boolean.TRUE
or Boolean.FALSE
.The official documentation is in the Javadoc.
UPDATED:
Autoboxing could also be used, but it has a performance cost.
I suggest to use it only when you would have to cast yourself, not when the cast is avoidable.