Get immediate superclass info in Java

Description

The following code shows how to get immediate superclass info.

Example


/* w  w  w  .  j  ava 2 s .c o  m*/
import java.util.Set;
import javax.swing.JDialog;

public class Main {

  public static void main(final String[] args) {
    System.out.println("JDialog --|> " + JDialog.class.getSuperclass());
    System.out.println("Integer --|> " + Integer.class.getSuperclass());
    System.out.println("Object --|> " + Object.class.getSuperclass());
    System.out.println("int --|> " + int.class.getSuperclass());
    System.out.println("int[] --|> " + int[].class.getSuperclass());
    System.out.println("Set --|> " + Set.class.getSuperclass());
    System.out.println("Comparable --|> " + Comparable.class.getSuperclass());
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy