Character.valueOf() in Java

Character.valueOf(): This method is available in java.lang.Character class of Java.

Syntax:

Character java.lang.Character.valueOf(char c)

This method takes one argument of type char as its parameter. This method returns a Character instance representing the specified char value. This method will always cache values in the range '\u005Cu0000' to '\u005Cu007F', inclusive, and may cache other values outside of this range.

Parameters: One parameter is required for this method.

c: a char value.

Returns: a Character instance representing c.

Exceptions: NA

Approach

Java

public class CharactervalueOf {
    public static void main(String[] args) {

        char c = 'a';
        System.out.println(Character.valueOf(c));

    }
}

Output:

a

No comments:

Post a Comment