java数据类型

一、基本数据类型

  boolean  char   byte  short  int   long  float  double

  boolean   8位

  char     16位  0-2^16-1

  byte     8位   -2^7-2^7-1

  short   16位  -2^15-2^15-1

  int     32位  -2^31-2^31-1

  long     64位  -2^63-2^63-1

  float    32位  单精度浮点数 可以将byte short int long char 赋值给float,java会自动转换

  double   64位  

  short s1 = 1;s1 = s1 + 1;错误

  需要强制转换,如果是s1 = 1+1;就是正确。

  short s1 = 1;s1+=1;正确

  相当于s1 = (short)(s1+1);

 

posted on 2016-11-23 00:58  wantcrazy  阅读(164)  评论(0编辑  收藏  举报

导航