Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Class.getTypeName() method is used to return 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 below example 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