Integer.class与int.class [英] Integer.class vs int.class

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

问题描述

Integer.class Integer.TYPE int之间有什么区别? class

acc to me

acc to me


  1. Integer.class 是Integer(Wrapper)类对象的引用

  2. 但是 int.class as int 不是类,它是原始类型。什么 Integer.TYPE 是指?

  1. Integer.class is a reference of Integer (Wrapper) Class object
  2. but what is then int.class as int is not a class, it's a primitive type. And what does Integer.TYPE refer to?


推荐答案

From java.lang.Class.isPrimitive API

From java.lang.Class.isPrimitive API

有九个预定义的Class对象来表示八种原始类型和无效。它们由Java虚拟机创建,并且与它们表示的基本类型具有相同的名称,即boolean,byte,char,short,int,long,float和double。

There are nine predefined Class objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double.

这些对象只能通过以下公共静态最终变量访问 java.lang.Boolean.TYPE java.lang.Integer.TYPE etc

These objects may only be accessed via the following public static final variables java.lang.Boolean.TYPE, java.lang.Integer.TYPE etc

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

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