Java Class - getTypeName() Method
The java.lang.Class.getTypeName() method returns an informative string for the name of this type.
Syntax
public String getTypeName()
Parameters
No parameter is required.
Return Value
Returns an informative string for the name of this type.
Exception
NA.
Example:
The example below shows the usage of java.lang.Class.getTypeName() method.
import java.lang.*; public class MyClass { public static void main(String[] args) { MyClass x = new MyClass(); Class cls = x.getClass(); //print the TypeName of the class String name = cls.getTypeName(); System.out.println("TypeName of class = " + name); } }
The output of the above code will be:
TypeName of class = MyClass
❮ Java.lang - Class