Boolean wrapper class


■ You cannot instantiate Boolean objects without a new.  i.e.


                        Boolean B = new Boolean("true");     works.

                        Boolean B = true;                         will not compile.


■ You cannot test for true or false in a Boolean using  ==. You must use the booleanValue( ) method.   i.e.


                        if ( B == true )                  will not compile.

                        if ( B.booleanValue( ) )       works.


■ You cannot assign primitive booleans to be null.  i.e.


                        boolean b = null;              will not compile.


Booleans can be null, because they’re objects. Boolean null always tests false.  i.e.


                        Boolean B = new Boolean( null ); 

                        if ( B.booleanValue( ) )                         returns false.


                        Boolean B = null; 

                        if( B.booleanValue( ) )                          will compile but will throw a runtime NullPointerException.


Boolean constructors will take as true any cases of the letters in "true". (Meaning Boolean's true is case-insensitive, but its false is not).  Providing anything other than various cases of the four letters t-r-u-e generates a value of false.  i.e.


                        Boolean B = new Boolean("tRuE");                   generates true.

                        Boolean B = new Boolean("TrUE");               generates true.

                        Boolean B = new Boolean("NotTrue");              generates false.

                        Boolean B = new Boolean("tru");                 generates false.