What different between Boolean and boolean in Java? | Sololearn: Learn to code for FREE!


What different between Boolean and boolean in Java?

12/14/2016 5:22:09 PM

Mahmood Ali

10 Answers

New Answer


smart question! boolean is a primitive and Boolean is as object wrapper. So boolean, is the type whose values are either true or false while the other is an object. If you wanted to convert a string to a boolean you could try Boolean.valueOf("true"). Because Boolean can be null, it can be used for lazy loading. As far as GWT, they are the same in GWT as there are in java. On Boolean, you will get more methods which will be useful. Second one (boolean) is cheap considering memory.


thank you ..


you are most welcome


To whoever minus voted my answer: are you sure you minused me for the right reasons? Just because a language is supposed to be used in a particular way, like we have here (I know the wrapper classes). But if value typed were not objects themselves, then how can java say that a particular value type of being of an exact defined size (normally it is the architecture that sets sizes for the bytes, words etc)? Java MUST make an object out of it in order typ garantuee an exakt size othet than HW limits. Or am I wrong?


boolean true,false;Boolean true,false,null


its only true and false,there's no major differences :)


their is no differenceđź‘·


Boolean may be used for tristate logic. Is capable of storing both true and false plus the null value too.


everything in java is essentially an object


Boolean is a variable declaration and boolean its a type that value suporte numbers.