Boolean - StarShipTutor/StarshipTutorAPCS GitHub Wiki

boolean : docs.oracle.com

Primitive Data Type - boolean

  • Contains - true or false
  • Default - false
  • Size - 1 bit
  • Range - NA

Wrapper Class - Boolean

The wrapper class Boolean is used to crate an object out of a boolean.

There are many useful static and instance methods. Here are a few

boolean a, b;

Boolean aBoolean, anotherBoolean;

String aString;

int theResult;

theResult = Boolean.compare    ( a, b );           // Static Method
theResult = aBoolean.compareTo ( anotherBoolean ); // Instance Method

// There are many methods for converting Boolean to Strings and vis versa 

// Static Methods

boolean theValue = Boolean.parseBoolean ( aString ); // converts string to boolean
String aString   = Boolean.toString ( a );           // converts boolean to string 

// and Instance Methods

boolean theValue = aBoolean.booleanValue ( ); // boolean value of Boolean object
String aString   = aBoolean.toString ();      // String of the Boolean object

See the full list at docs.oracle.com