Java Program to Get the List of Implemented Interfaces in a Class

Java program to get the list of implemented interfaces in a class

// Java program to get the list of implemented interfaces 
// in a class

interface inf1 {}

interface inf2 {}

class Sample implements inf1, inf2 {}

public class Main {
  public static void main(String[] args) throws ClassNotFoundException {
    Class cls = Class.forName("Sample");
    Class cInf[] = cls.getInterfaces();

    System.out.println("Interfaces implemented by Sample class: ");
    for (Class inf: cInf)
      System.out.println(inf);
  }
}

Output

Interfaces implemented by Sample class: 
interface inf1
interface inf2
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment