Convert class to string
String toString()
- Converts the object to a string.
public class Main {
public static void main(String[] args) {
Class c = new String().getClass();
System.out.println(c.getName());
System.out.println(c.toString());
}
}
The output:
java.lang.String
class java.lang.String