Integer.class和Integer.TYPE之间的区别 [英] Difference between Integer.class and Integer.TYPE

查看:905
本文介绍了Integer.class和Integer.TYPE之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两者有什么区别?原始类型不能有类,可以 - 它是原始的。没有对象可以上课。

What is the difference between these two? A primitive type cannot have "Class", can it - it is primitive. There are no objects to have a class.

这两者有何区别?

推荐答案

我不是肯定你的意思,但是 - Class 对象是一个类型的运行时代表。也就是说,有一个 int.class 这样的东西与 Integer.class 不同,即使 int 不是一个类。它有点复杂,但有必要使反射工作甚至在采用原始参数或返回原始值的方法上,或者区分接受 Integer 的方法与接受 int

I'm not positive what you mean, but -- A Class object is a runtime representative of a type. That said, there is such a thing as int.class that is distinct from Integer.class, even though int is not a class. It's kind of complicated, but it's necessary to make reflection work even on methods that take primitive arguments or return primitive values, or to distinguish a method that accepts an Integer from a method that accepts an int.

Integer.TYPE ,I相信,相当于 int.class

这篇关于Integer.class和Integer.TYPE之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆