Is it possible to use a primitive type (int) in as a generic type in Java?

岁酱吖の 提交于 2019-11-27 09:24:19

No, this is not possible. Use Integer instead. Autoboxing takes care of the rest (i.e. for most purposes you can program as if you had actually used int because Java converts to and from Integer automatically for you).

Konrad is correct. Alternately, you can use the trove class TObjectIntHashMap to map Objects to primitive ints.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!