String.valueOf(Object obj) has the following syntax.
public static String valueOf(Object obj)
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)); } }
The code above generates the following result.