There are discussions around Integer
vs int
in Java. The default value of the former is null
while in the latter it's 0
. How about Boolean
vs boolean
?
A variable in my application can have 0
/1
values. I would like to use boolean
/Boolean
and prefer not to use int
. Can I use Boolean
/boolean
instead?
Yes you can use Boolean
/boolean
instead.
First one is Object and second one is primitive type.
On first one, you will get more methods which will be useful.
Second one is cheap considering memory expense The second will save you a lot more memory, so go for it
Now choose your way.