Common Java classes --Character class

Character class is used to operate a single character, the object packaged in a value of the primitive type char.
Character class provides a series of methods to manipulate character. You can create an object using the Character class constructor Character when you a char type of parameters passed to require a Character type parameter method, then the compiler will automatically be converted to char type parameters Character type parameter, so we you can call packing, unpacking and vice versa for.

In the Character class, we also need to know the escape sequence (preceded by a backslash () characters represent the escape character, it is the compiler has special meaning)

Character classes of commonly used methods:

1, isLetter () method

isLetter () method for determining the specified character is a letter.

Syntax: boolean isLetter (char ch)

Ch = in which characters to be measured; when is a letter, it returns true, otherwise returns false. (Hereinafter ch are to be measured characters)

2, isDigit () method

isDigit () method for determining whether a designated character is a digit, if the character is a number, the return true; otherwise returns false.

Syntax: public static boolean isDigit (char ch)

3, isWhitespace () method

isWhitespace () method for determining whether or not the specified character is a blank character, whitespace comprising: space, tab key, line feed, if the character is a blank character, then returns true; otherwise returns false.

Syntax: boolean isWhitespace (char ch)

4, isUpperCase () method

isUpperCase () method for determining the specified character is a capital letter, if the character is uppercase, return true; otherwise returns false.

Syntax: boolean isUpperCase (char ch)

5, isLowerCase () method

isLowerCase () method for determining the specified character is a lowercase letter, if the character is a lowercase Returns true; otherwise returns false.

Syntax: boolean isLowerCase (char ch)

6, toUpperCase () method

toUpperCase () method is used to convert lowercase characters to uppercase, uppercase if any, returns the converted character; otherwise the character itself.

Syntax: char toUpperCase (char ch)

7, toLowerCase () method

toLowerCase () method is used to convert uppercase to lowercase, lowercase if any, returns the converted character; otherwise the character itself.

Syntax: char toLowerCase (char ch)

8, toString () method

toString () method returns a String object for the specified char FIG. The result is a string of length 1, only the composition of the specified char.

Syntax: String toString (char ch)

For a complete list of methods, see the java.lang.Character API specification.

Guess you like

Origin www.cnblogs.com/jingxinbk/p/12422792.html