How do I check if a class represent an interface type?

You can use the isInterface() method call of the java.lang.Class to identify if a class objects represent an interface type.

package org.kodejava.example.lang.reflect;


public class IsInterfaceDemo {
    public static void main(String[] args) {

    private static void get(Class clazz) {
        if (clazz.isInterface()) {
            System.out.println(clazz.getName() +
                    " is an interface type.");
        } else {
            System.out.println(clazz.getName() +
                    " is not an interface type.");

Here is the result of the program: is an interface type.
java.lang.Long is not an interface type.

How do I know if a class object is an interface or a class?

package org.kodejava.example.lang;

public class CheckForInterface {
    public static void main(String[] args) {
        // Checking whether Cloneable is an interface or class
        Class clazz = Cloneable.class;
        boolean isInterface = clazz.isInterface();
        System.out.println("Cloneable is an interface = " + isInterface);

        // Checking whether String is an interface or class
        clazz = String.class;
        isInterface = clazz.isInterface();
        System.out.println("String is an interface = " + isInterface);
Cloneable is an interface = true
String is an interface    = false