主程序:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
方法1:
- 1
- 2
- 3
- 4
- 5
以上方法得到一个类的Field 属性,然后设置可见性,然后设置了一个值,最后打印
方法2:
- 1
- 2
- 3
- 4
最后的打印结果:
调用方法一
test
调用方法二
set
test2
也就是说,第一种方法,没有调用属性的set方法就完成了赋值,但是第二种方法,是通过调用属性的set方法来完成赋值。
主程序:
方法1:
以上方法得到一个类的Field 属性,然后设置可见性,然后设置了一个值,最后打印
方法2:
最后的打印结果:
调用方法一
test
调用方法二
set
test2
也就是说,第一种方法,没有调用属性的set方法就完成了赋值,但是第二种方法,是通过调用属性的set方法来完成赋值。