The Best Technical Blog Ever

twitterrss

Characters Class in java

Primitive char type is used for single character value. For example:


char ch = 'x';  
char[] charArray = { 'x', 'y', 'z' }; // an array of chars  

Whenever you need to use a char as an object, Java provides a wrapperclass that "wraps" the char in a Character object. With the help of Character constructor, we can create a Character object.


Character charobj = new Character('x');

The Java compiler will also create a Character object , when you pass a primitive char into a method that expects an object. In such case, compiler automatically converts the char to a Character for you.



Sl.No Character Methods Description
1 isLetter(char c) It determines whether the specified char value is a letter.
2 isDigit(char c) It determines whether the specified char value is a digit.
3 isUpperCase(char c) It determines whether the specified char value is uppercase.
4 isLowerCase(char c) It determines whether the specified char value is lowercase.
5 isWhitespace(char c) It determines whether the specified char value is white space.
6 toUpperCase(char c) It returns the uppercase of the specified char value.
7 toLowerCase (char c) It returns the lowercase of the specified char value.
8 toString(char c) It returns a String object(one-character string) representing the specified character value.


Escape Sequences:

Escape sequence is a character preceded by a backslash (\) that has special meaning to the compiler.



Sl.No Escape Sequence Description
1 \t It inserts a tab in the text at this point.
2 \b It inserts a backspace in the text at this point.
3 \n It inserts a newline in the text at this point.
4 \r It inserts a carriage return in the text at this point.
5 \f It inserts a form feed in the text at this point.
6 \' It inserts a single quote character in the text at this point.
7 \" It inserts a double quote character in the text at this point.
8 \\ It inserts a backslash character in the text at this point.

If you want to print quotes within quotes in a print statement, you must use the escape sequence, \", on the interior quotes:


Example:
escape sequence

Keypoints to remember in java

1. Java is a high level, robust, secured , platform independent and object oriented programming.... more info

Back to Basics:- Java Syntax

In this session, you are going to refresh some basic set of rules(java syntax), defining how a ... more info

Total Visits
Traffic feed status