Get interfaces implemented by a class Reflection Java


It is advised to read the notes on Java Reflection API before attempting the programs.

Example to get interfaces implemented by a class
interface Hello {  }
interface Test {  }
interface Sample  extends Test, Hello{  }
public class Demo implements Hello, Test, Sample
{
  public static void main(String args[])
  {
     Demo d1 = new Demo();
     Class c = d1.getClass();

     Class c1[] = c.getInterfaces();
     for(int i = 0; i < c1.length; i++)
     {
        System.out.println(c1[i]);
     }
  }
}

2 thoughts on “Get interfaces implemented by a class Reflection Java”

Leave a Comment

Your email address will not be published.