java.lang.reflect.Modifier.isInterface() Method Example


Advertisements

Description

The java.lang.reflect.Modifier.isInterface(int mod) method return true if the integer argument includes the interface modifier, false otherwise.

Declaration

Following is the declaration for java.lang.reflect.Modifier.isInterface(int mod) method.

public static boolean isInterface(int mod)

Parameters

mod − a set of modifiers.

Returns

true if mod includes the interface modifier; false otherwise.

Example

The following example shows the usage of java.lang.reflect.Modifier.isInterface(int mod) method.

package com.tutorialspoint;

import java.lang.reflect.Modifier;

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

      System.out.println(Modifier.isInterface(SampleClass.class.getModifiers()));
   }
}

interface SampleClass {
   String getSampleField();
}

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

true
java_reflect_modifier.htm
Advertisements