Get implemented interfaces

 
import java.io.IOException;
import java.io.RandomAccessFile;

public class SampleInterface {

  public static void main(String[] args) {
    try {
      RandomAccessFile r = new RandomAccessFile("myfile", "r");
      printInterfaceNames(r);
    } catch (IOException e) {
      System.out.println(e);
    }
  }

  static void printInterfaceNames(Object o) {
    Class c = o.getClass();
    Class[] theInterfaces = c.getInterfaces();
    for (int i = 0; i < theInterfaces.length; i++) {
      String interfaceName = theInterfaces[i].getName();
      System.out.println(interfaceName);
    }
  }
}
  
Home 
  Java Book 
    Runnable examples  

Reflection interface:
  1. Get implemented interfaces
  2. Get Super Interfaces
  3. Is it an interface
  4. Does it implement Serializable interface
  5. Interfaces for a primitive type is an empty array
  6. Superclass of interfaces is always null