开发者

Java Reflection : internals of java.lang.reflect.Field.getDouble(object)

Does anyone know if Field.getDouble(Object) boxes and unboxes a double internally?

Th开发者_开发技巧anks, RB


If you use Field.getDouble() on a double field, there is no auto boxing/unboxing. This method existed long before this was available.


Per the Sun/Oracle Reflection API tutorial:

When using reflection, type checking only occurs at runtime so there is no opportunity to box the value. ...To eliminate this exception, the problematic line should be replaced by the following invocation of Field.set(Object obj, Object value): f.set(ft, new Integer(43));

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜