Java Modifier.isPublic(int mod)

Syntax

Modifier.isPublic(int mod) has the following syntax.

public static boolean isPublic(int mod)

Example

In the following code shows how to use Modifier.isPublic(int mod) method.


//from w  w  w.  j  av  a 2 s  .c  o  m
import java.lang.reflect.Modifier;

public class Main {
  public static void main(String[] args) throws Exception {
    Class<?> clazz = String.class;
    int modifier = clazz.getModifiers();

    if (Modifier.isPublic(modifier)) {
      System.out.println("isPublic");
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable