中易网

Java:这里的Field.get(null)是在干什么呢,费解

答案:2  悬赏:50  
解决时间 2021-01-14 09:41
  • 提问者网友:太高姿态
  • 2021-01-13 10:13
Java:这里的Field.get(null)是在干什么呢,费解
最佳答案
  • 二级知识专家网友:蕴藏春秋
  • 2021-01-13 11:32
public Object get(Object obj)      throws IllegalArgumentException,      IllegalAccessException

Returns the value of the field represented by this
Field, on the specified object. The value is automatically wrapped
in an object if it has a primitive type.


The underlying field's value is obtained as follows:
If the underlying field is a static field, the obj argument is
ignored; it may be null. 


API中说明如果是静态字段,则get的参数会被忽略。所以上面的代码应该是专门获取该类中的静态字段用的。
全部回答
  • 1楼网友:妄饮晩冬酒
  • 2021-01-13 12:53
看API,没见过,但是API里肯定有讲
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息