Javatpoint Logo
Javatpoint Logo

Java Character valueOf() Method

The valueOf(char c)method of Character class returns the instance of the Character which represents the given char value. If the new object of the Character is not required, then the method should be used in preference to the constructor Character(char).

The above method is likely to provide better space and time performance. This method will cache the values in the range of '\u0000' to '\u007F' and there might be some possibilities to cache the other values outside the range.

Syntax

Parameters

c: It is the character value that needs to be tested.

Return Value

The valueOf(char c)method returns the object of Character.

Example 1

Test it Now

Output:

The character value of the character 'A' is given as: A
The character value of the character 'h' is given as: h

Example 2

Test it Now

Output:

The word 'Hello' can be represented as:
H
e
l
l
o
The word 'Everyone' can be represented as:
E
v
e
r
y
o
n
e
Next TopicJava Character




Help Others, Please Share

facebook twitter pinterest