Simple way to get wrapper class type in Java

前端 未结 9 1455
天命终不由人
天命终不由人 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:42

    Apache Commons Lang has a utility method to do this (ClassUtils.primitiveToWrapper()), which will be just as ugly under the covers, but at least you can pretend it's nice.

提交回复
热议问题