Simple way to get wrapper class type in Java

前端 未结 9 1435
天命终不由人
天命终不由人 2020-11-29 09:14

I have a piece of code where I need to pass the class of a field in a method. Because of the mechanics of my code I can only handle reference objects and not primitives. I w

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 09:47

    You can call class.isPrimitive() to know if it is a primitive or not, however, there is no boxing method to convert the classes within the JDK. There is at least one open bug relating to this.

提交回复
热议问题