Differences among various bool types?
What are the differences among bool, boolean and Boolean in 开发者_如何学运维Java/Android?
bool
does not seem to exist, at least I can't find references to it.
boolean
is a primitive boolean type, not an object.
Boolean
is the wrapper object for a boolean
.
boolean
is a java primitive type. It only accepts true
or false
(which are declared constants in java).
Boolean is a Serializable wrapper of boolean
primitive type. From the JDK....
The
Boolean
class wraps a value of the primitive type boolean in an object. An object of type Boolean contains a single field whose type isboolean
.
bool
doesn't exist in java, but it does in Android as R.bool
.
boolean is a primitive boolean type and occupies less memory. Boolean is the wrapper object for a boolean which introduced in JDK 1.5.
- Suppose you have a service API which will execute a query and get the data from multiple tables.
- After that this data is to be manipulated and converted into the json object.
- During this conversion, it ight be possible that some boolean field may have 'NULL' as value.
- While receiving it as a response, you will definately parse it into an object.
- This automatic conversion may fail if your conversion logic will try to parse Boolean 'NULL' value into boolean primitive variable because boolean can't accept 'NULL' values.
精彩评论