Sunday, July 9, 2023

WRAPPER CLASS-CHARACTER

 Constructor

Character(char c)


Methods: 

1. isLetter (): This method returns a boolean value, i.e true or false. It returns true if the argument passed in the method is a letter i.e any character in between a-z and A-Z. Otherwise it returns false.

2.isDigit(): The isDigit method as the name suggests checks whether the parameter passed to it is a digit or not. It returns true if the argument passed is a digit. Else it returns false.

3.sWhitespace(): It checks whether the value of the argument passed is a white space or not. However this method also returns true if the argument is a tab or new line.

4.isUppercase(): This method is primarily used for checking whether the character passed in the argument is an UpperCase character or not. It returns true if the character is in Uppercase. If not, it returns false.

5.isLowercase(): This method is primarily used for checking whether the character passed in the argument is a LowerCase character or not. It returns true if the character is in LowerCase. If not, it returns false.

6.toUpperCase(): This method is a character returning method. This takes the argument and converts it into an uppercase alphabet. It returns an uppercase alphabet.

7.toLowerCase (): Java toLowerCase method converts the arguments passed to it into lowercase. However, if a numeric value i.e ASCII value of an UpperCase letter is passed through it returns the ASCII value of the corresponding lowercase alphabet.

8.toString (): This method has the responsibility of converting the character arguments passed through it, to String objects for manipulation as and when required by the programmer. ASCII values cannot be passed as arguments here.



Escape Sequences in Java

There are some particular characters, which when preceded with a backslash(\), holds special meaning to the compiler. Some of the escape sequences are:


\n- creates a new line

\t- creates a tab space

\b- inserts a single backspace

\r-inserts carriage return

\\- inserts a backslash character

\’- inserts single quote character

\” – inserts double-quote character



REF:https://data-flair.training/

No comments:

Post a Comment