The toString() method of java.lang.Class class is used to convert the instance of this Class to a string representation. This method returns the formed string representation.
public String toString()
Parameter: This method does not accept any parameter.
Return Value: This method returns the String representation of this object.
Below programs demonstrate the toString() method.
Class represented by c1: class java.lang.String
Class represented by c2: int Class represented by c3: void
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.