Java Class.getInterfaces()

Syntax

Class.getInterfaces() has the following syntax.

public Class <?>[] getInterfaces()

Example

In the following code shows how to use Class.getInterfaces() method.


/*w w  w .j a v  a 2 s.c  o  m*/
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Class cls = Thread.class;
    System.out.println("Class = " + cls.getName());

    Class[] c = cls.getClasses();
    System.out.println("Classes = " + Arrays.asList(c));

    // returns an array of interfaces
    Class[] i = cls.getInterfaces();
    System.out.println("Interfaces = " + Arrays.asList(i));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable