Java Reflection - Java Field.isSynthetic()








Syntax

Field.isSynthetic() has the following syntax.

public boolean isSynthetic()

Example

In the following code shows how to use Field.isSynthetic() method.

/*w w w .j  a v a  2s  . c o m*/
import java.lang.reflect.Field;

enum Spy {
  BLACK, WHITE
}

public class Main {

  public static void main(String... args)throws Exception {
      Class<?> c = Class.forName("Spy");
      Field[] flds = c.getDeclaredFields();
      for (Field f : flds) {
          System.out.println(f.isSynthetic());
        
      }
  }
}

The code above generates the following result.