Char - StarShipTutor/StarshipTutorAPCS GitHub Wiki

char : docs.oracle.com

Primitive Data Type - char

  • Contains - Unicode character, the numerical value is called a code point
  • Default - \u0000
  • Size - 16 bits
  • Range - \u0000 to \uFFFF

Wrapper Class - Character

The wrapper class Character is used to crate an object out of a char.

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

char a, b;

Character aCharacter, anotherCharacter;

String aString;
int theResult;

theResult = Character.compare    ( a, b );             // Static Method
theResult = aCharacter.compareTo ( anotherCharacter ); // Instance Method

// Static Methods

int radix;  // an integer signifying the base, usually 2, 8, 10 or 16
int aDigit; // an integer for a digit ( e.g. 15 == F in Hex )

int  theValue = Character.digit    ( a, radix ); // converts char digit to integer value
char theChar  = Character.forDigit ( aDigit, radix ); // converts int value of digit to char 

// and Instance Methods

char theValue  = aCharacter.cahrValue (); // char value of Character object
String aString = aCharacter.toString ();  // String of the Character value

See the full list at docs.oracle.com