首页 > 试题广场 >

Java支持的数据类型有哪些?什么是自动拆装箱?

[问答题]
请你讲讲Java支持的数据类型有哪些?什么是自动拆装箱?
java有八大基本类型 int byte short long fltoat double char boolean 每个类型都有它的包装类 Integer Byte Short Long Float Double Character Boolean 自动装箱:Java自动将原始类型值转换成对应的对象,比如将int的变量转换成Integer对象,这个过程叫做装箱。 自动拆箱就是:反之将Integer对象转换成int类型值,这个过程叫做拆箱。因为这里的装箱和拆箱是自动进行的非人为转换,所以就称作为自动装箱和拆箱。 原理: 1)自动装箱时编译器调用valueOf将原始类型值转换成对象。 2)同时自动拆箱时,编译器通过调用类似intValue(),doubleValue()这类的方法将对象转换成原始类型值。 举例: Integer i = 11;//自动装箱,实际上执行了Integer i = Integer.valueOf(11); int t = i;//自动拆箱,实际上执行了 int t = i.intValue();
编辑于 2019-02-28 09:48:09 回复(0)
java中有8大基本数据类型byte、short、int、long、float、double、boolean、char,而每种基本数据类型都有所对应的封装类Byte、Short、Integer、Long、Float、Double、Boolean、Charactor,将基本数据类型转换为所对应的封装类的过程叫做装箱,将封装类转换为基本数据类型的过程叫做拆箱。而这里的装箱和拆箱的过程是自动进行的,所以叫做自动拆装箱。
发表于 2019-08-05 13:55:11 回复(0)
Java语言支持的8种基本数据类型是: byte short int long float double boolean char
发表于 2019-05-08 10:31:43 回复(0)
byte,int,short,long,float,chart,boolean,double
编辑于 2019-04-30 21:47:57 回复(0)
八大基本类型 int short long boolean byte float char double 装箱 就是把基本类型用它们相对应的引用类型包起来 使它们可以具有对象的特质 如我们可以把int型包装成Integer类的对象 或者把double包装成Double 等等 拆箱 就是跟装箱的方向相反 将Integer及Double这样的引用类型的对象重新简化为值类型的数据
发表于 2019-04-27 16:42:38 回复(0)
int byte short long fltoat double char boolean装箱就是自动将基本数据类型转换为包装类型;拆箱就是自动将包装类型转换为基本数据类型。
编辑于 2019-04-26 23:27:45 回复(0)
1.八大基本数据类型:byte,short,char,int,float,long,boolean,double;int对应的对象类是Integer,char对应的对象类是Character,其他都是首字母大写;
  • 自动装箱:Java自动将原始类型值转换成对应的对象 例如Integer-int
  • 自动拆箱:反过来,例如int->Integer
发表于 2019-04-26 21:15:28 回复(0)
Java语言支持的8种基本数据类型是:  byte  short  int  long  float  double  boolean  char  自动装箱是Java编译器在基本数据类型和对应的对象包装类型之间做的一个转化。
发表于 2019-04-25 22:07:28 回复(0)
Java支持8种基本数据类型:byte,char,short,int,long,boolean,double,float
及他们都有与之对应的封装类integer Long Short Folat Boolean Char Byte Double
发表于 2019-04-25 20:39:06 回复(0)
int,double.float,short,long,boolean,byte,char
发表于 2019-04-25 20:23:49 回复(0)
Java支持8种基本数据类型:byte,char,short,int,long,boolean,double,float。jdk1.5后可以自动实现基本数据类型的装箱和拆箱。装箱是指,将基本数据转化成对象。转化为对象可以方便的操作数据。利用面向对象的方法方便的实现对数据的操作。拆箱就是装箱的逆过程。
发表于 2019-04-25 19:13:13 回复(0)
java中的8种基本数据类型:boolean byte char short int float double long
自动拆装箱的问题引入:
由于在一开始学习java的时候,”万物皆对象“这种面向对象的看问题方式,时刻围绕在脑海中。因为静态的变量和基本数据类型不属于对象,但是由8种基本数据类型的自动装拆箱解决了基本数据类型不是对象。
在jdk1.5中引入了自动拆装箱的新特性,在jdk1.5之前,我们想要使用integer类中的方法,我们先要把int变量变成integer类型,可以通过new Integer(intNumber) 或者调用Integer.valueOf(intNumber)方法
发表于 2019-04-25 18:52:29 回复(0)
八大基本数据类型: byte  short  int  long  float  double  boolean  char
发表于 2019-04-25 17:48:26 回复(0)
八大基本数据类型 int long short float boolean char byte double 及他们都有与之对应的封装类integer Long Short Folat Boolean Char Byte Double
发表于 2019-04-25 16:21:44 回复(0)

八大基本数据类型

基本类型 大小 封装类
boolean 未知字节 Boolean
byte 1字节 Byte
char 2字节 Charactor
short 2字节 Short
int 4字节 Integer
long 8字节 Long
float 4字节 Float
double 8字节 Double

若说是九种的话,则加上void

  • 自动装箱:Java自动将原始类型值转换成对应的对象 例如Integer-int
  • 自动拆箱:反过来,例如int->Integer
发表于 2019-04-02 15:38:04 回复(0)
int float string double long byte short char int转化成Integer,double转换为Double为自动装箱,反之为自动拆箱
编辑于 2019-01-07 18:27:36 回复(1)