1.数据类型

  • 基本数据类型

  1.整数

byte      1字节   

short     2字节

int       4字节

long      8字节

   2.浮点数

float          4字节

double       8字节

  3.字符

           char           2字节   

  4.布尔

    boolean       1字节   

  • 整数默认是 int  浮点数默认是 double
  • 数据类型隐式转换   byte  short char → int → long → float → double

  注意点

Class Test{
  public void main(String[]){

        byte  a=1,b=2,c;
        c=a+b;                //error    a+b会进行数据提升为int类型
        c=3+4;                // success  编译时期,常量相加时会先相加,然后判断是否在被赋值变量数据类型范围之内,如果在,就直接赋值,不会进行数据类型转换
  }
}
  • 引用数据类型

 1.class

 2.interface

 3.数组

 

posted @ 2017-03-07 15:49  不识  阅读(99)  评论(0编辑  收藏  举报