JAVA TUTORIALS - Java - Characters
Java - Characters
ADVERTISEMENTS
Escape Sequences:
Escape Sequence | Description |
---|---|
\t | Inserts a tab in the text at this point. |
\b | Inserts a backspace in the text at this point. |
\n | Inserts a newline in the text at this point. |
\r | Inserts a carriage return in the text at this point. |
\f | Inserts a form feed in the text at this point. |
\' | Inserts a single quote character in the text at this point. |
\" | Inserts a double quote character in the text at this point. |
\\ | Inserts a backslash character in the text at this point. |
ADVERTISEMENTS
Character Methods:
SN | Methods with Description |
---|---|
1 | isLetter() Determines whether the specified char value is a letter. |
2 | isDigit() Determines whether the specified char value is a digit. |
3 | isWhitespace() Determines whether the specified char value is white space. |
4 | isUpperCase() Determines whether the specified char value is uppercase. |
5 | isLowerCase() Determines whether the specified char value is lowercase. |
6 | toUpperCase() Returns the uppercase form of the specified char value. |
7 | toLowerCase() Returns the lowercase form of the specified char value. |
8 | toString() Returns a String object representing the specified character valuethat is, a one-character string. |
ADVERTISEMENTS
Example:
char ch = 'a'; // Unicode for uppercase Greek omega character char uniChar = '\u039A'; // an array of chars char[] charArray ={ 'a', 'b', 'c', 'd', 'e' };
Character ch = new Character('a');Example:
// Here following primitive char 'a' // is boxed into the Character object ch Character ch = 'a'; // Here primitive 'x' is boxed for method test, // return is unboxed to char 'c' char c = test('x');Example:
public class Test { public static void main(String args[]) { System.out.println("She said \"Hello!\" to me."); } }
She said "Hello!" to me.