Java.lang.Character.valueOf() is an inbuilt method in Java that returns a Character instance representing the specified char value. If a new Character instance is not required, this method is generally used in preference to the constructor Character(char), since this method is likely to yield significantly better space and time performance by caching frequently requested values. This method will always cache values range [‘\u0000’ to ‘\u007F’] inclusive and may cache other values outside of this range.
public static Character valueOf(char ch) Parameter: ch- this parameter specifies the character.
Returns: This method returns a Character instance representing ch.
The program below demonstrates the Java.lang.Character.valueOf() function:
Character value of z is z
Character value of 5 is 5
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.