Skip to content

Instantly share code, notes, and snippets.

@wuyexiong
Created August 10, 2013 17:59
Show Gist options
  • Select an option

  • Save wuyexiong/6201437 to your computer and use it in GitHub Desktop.

Select an option

Save wuyexiong/6201437 to your computer and use it in GitHub Desktop.
反射获取类成员的属性
// Declare and initialize a Class object:
Class mc = java.lang.Byte.class;
// Declare and initialize a field object:
Field field = mc.getField("MIN_VALUE");
// Get the integer value of the modifiers:
int mod = field.getModifiers();
// Get the string value of the modifiers:
System.out.println("The modifiers are: " + Modifier.toString(mod));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment