Java.lang.Class.isInterface() Method

Advertisements


Description

The java.lang.Class.isInterface() determines if the specified Class object represents an interface type.

Declaration

Following is the declaration for java.lang.Class.isInterface() method

public boolean isInterface()

Parameters

  • NA

Return Value

This method returns true if this object represents an interface, else false.

Exception

  • NA

Example

The following example shows the usage of java.lang.Class.isInterface() method.

package com.tutorialspoint;

import java.lang.*;

public class ClassDemo {

   public static void main(String[] args) {

     ClassDemo c = new ClassDemo();
     Class cls = c.getClass();

     // determines if the specified Class object represents an interface type
     boolean retval = cls.isInterface();
     System.out.println("It is an interface ? " + retval);       
   }
}

Let us compile and run the above program, this will produce the following result:

It is an interface ? false



Advertisements
Advertisements