Java String.valueOf(Object obj)
Syntax
String.valueOf(Object obj) has the following syntax.
public static String valueOf(Object obj)
Example
In the following code shows how to use String.valueOf(Object obj) method.
public class Main {
public static void main(String args[]) {
Object objectRef = "hello"; // assign string to an Object reference
System.out.printf("Object = %s\n", String.valueOf(objectRef));
//w w w. ja v a 2 s .co m
}
}
The code above generates the following result.