Home >Java >javaTutorial >Detailed explanation of examples of .lang.reflect.Modifier.isInterface() method in java

Detailed explanation of examples of .lang.reflect.Modifier.isInterface() method in java

黄舟
黄舟Original
2017-09-07 10:22:071900browse

This article mainly introduces the relevant information about the java.lang.reflect.Modifier.isInterface() method. Here are examples to help you understand the use of this method. Friends in need can refer to it

Detailed explanation of java.lang.reflect.Modifier.isInterface() method

java.lang.reflect.Modifier.isInterface(int mod) method determines if the given mod parameter contains the final modifier, then Returns true, otherwise returns false.

Declaration

The following is the declaration of the java.lang.reflect.Modifier.isInterface() method.


public static boolean isInterface(int mod)

Parameters

mod - A set of modifiers.

Return value

True if the mod contains the interface modifier; otherwise: false.

Example

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


 package com.yiibai;
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 results -


true

The above is the detailed content of Detailed explanation of examples of .lang.reflect.Modifier.isInterface() method in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn