O'Reilly logo

Java in a Nutshell, 5th Edition by David Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Character

Synopsis

This class provides an immutable object wrapper around the primitive char data type. charValue( ) returns the char value of a Character object. The compareTo( ) method implements the Comparable interface so that Character objects can be ordered and sorted. The static methods are the most interesting thing about this class, however: they categorize char values based on the categories defined by the Unicode standard. (Some of the methods are only useful if you have a detailed understanding of that standard.) Static methods beginning with “is” test whether a character is in a given category. isDigit( ) , isLetter( ), isWhitespace( ), isUpperCase( ) and isLowerCase( ) are some of the most useful. Note that these methods work for any Unicode character, not just with the familiar Latin letters and Arabic numbers of the ASCII character set. getType( ) returns a constant that identifies the category of a character. getDirectionality( ) returns a separate DIRECTIONALITY_ constant that specifies the “directionality category” of a character.

In addition to testing the category of a character, this class also defines static methods for converting characters. toUpperCase( ) returns the uppercase equivalent of the specified character (or returns the character itself if the character is uppercase or has no uppercase equivalent). toLowerCase( ) converts instead to lowercase. digit( ) returns the integer equivalent of a given character in a given radix (or base; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required