Java - String valueOf() Method
The Java string valueOf() method returns the string representation of the char argument.
Syntax
public static String valueOf(char c)
Parameters
c |
specify a char. |
Return Value
Returns a string of length 1 containing as its single character the argument c.
Exception
NA.
Example:
In the example below, valueOf() method returns the string representation of the given argument.
import java.lang.*; public class MyClass { public static void main(String[] args) { char x1 = 'a'; System.out.println(String.valueOf(x1)); char x2 = 'A'; System.out.println(String.valueOf(x2)); } }
The output of the above code will be:
a A
❮ Java.lang - String