ExceptionsTopMiscellaneous interesting String methods:Characters

Characters

A character is represented internally as a number ­ an integer, in fact. There are various "universal" codes that can be used to represent chars:

To declare a variable to be of character type:

    private char letter;

Use single quotes for character constants: 'H' is a char; "H" is a String:

    char letter = 'H';
Demo 4. Using charAt and information about

characters to fix the color mixer demo from weeks ago. See the color mixer demo. Notice how it behaves if you include a non-digit in the input.


ExceptionsTopMiscellaneous interesting String methods:Characters