基本包装(八中基本类型对应的包装类)

定义:程序界面用户输入的数据都是以字符串类型存储的--》基本数据类型
八中基本数据类型对应的包装类:
char-------Character
int----------Integet
Byte--------Byte
short-------Short
long---------Long
float---------Float
double-------Double
boolean------Boolean

案例:
package cn.lijun.demo1;

public class InterDemo {
//基本转引用是拆箱  引用转基本是装箱
    public static void main(String[] args) {
        
                fun();
    }
    public static void fun(){
        Integer j=new Integer(1); //装箱的过程   1.5版本之后可以省略不写
        Integer i=1;        //i是引用类型  不能和引用类型进行运算
        //自动拆箱 转换成int 基本类型
        int g=i-1;
        System.out.println(g);
    }

}

 

posted @ 2019-03-21 11:57  芯-觞  阅读(567)  评论(0编辑  收藏  举报