How do I get interfaces implemented by a class?

The getClass().getInterfaces() method return an array of Class that represents the interfaces implemented by an object.

package org.kodejava.example.lang;

import java.util.Date;
import java.util.Calendar;

public class ClassInterfaces {
    public static void main(String[] args) {
        // Get an instance of Date class
        Date date = Calendar.getInstance().getTime();

        // Get all interfaces implemented by the java.util.Date class and
        // print their names.
        Class[] interfaces = date.getClass().getInterfaces();
        for (Class iface : interfaces) {
            System.out.println("Interface Name = " + iface.getName());

        // For the primitive type the interface will be an empty array.
        Class c = char.class;
        interfaces = c.getInterfaces();
        for (Class iface : interfaces) {
            System.out.println("Interface Name = " + iface.getName());

The java.util.Date class implements the following interfaces:

Interface Name =
Interface Name = java.lang.Cloneable
Interface Name = java.lang.Comparable

Wayan Saryada

Founder at Kode Java Org
I am a programmer, a runner, a recreational diver, currently live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. You can support my works by donating here. Thank you 🥳

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.