In this tutorial we are going to learn hot get interfaces implemented by class at run time . To get interfaces implemented by class , getInterfaces() method was provided in java.lang.Class class . getInterfaces() method returns Class[]. See the below example .

package com.java;

interface I1{
}
interface I2{
}
class Sample implements I1,I2
{
    public static void main(String[] args) throws ClassNotFoundException
    {
    Class c1=Class.forName("com.java.Sample");
    Class c2[]=c1.getInterfaces();
    for(Class c3:c2)
        {
        System.out.println(c3.getName());
        }
    }
}
/* 

Output :

com.java.I1
com.java.I2

*/ 

Using getInterfaces() method we can get directly implemented interfaces only. To get complete interface hierarchy , see the below example .