Created
August 10, 2013 17:59
-
-
Save wuyexiong/6201437 to your computer and use it in GitHub Desktop.
反射获取类成员的属性
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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