- package day23;
- import java.lang.reflect.Field;
- public class IntegerArraylistAddString {
- public static void main(String[] args)throws Exception {
- GetSum gs=new GetSum(2,3);
- Field field1=gs.getClass().getField("y");
- int mm=(int)field1.get(gs);
- System.out.println(mm);
- //Field field2=gs.getClass().getDeclaredField("x");
- //field2.setAccessible(true);
-
- //System.out.println(field2.get(gs));
-
-
- }
- }
- class GetSum
- {
- int x;
- int y;
- public GetSum(int x, int y) {
- super();
- this.x = x;
- this.y = y;
- }
-
- }
复制代码 |
|