java 基本数据类型之四类八种

四类

  整   型

  浮点型

  字符型

  布尔型

八种

  整  型: byte  字节数  1  数据表示范围       默认值:0

          short                默认值:0

        int                 默认值:0

        long                默认值:0

  浮点型:float                默认值:0.0

      double               默认值:0.0

  字符型:char                默认值:u0000     注意  字符型和字符串(不属于基本类型)不一样

  布尔型:boolean              默认值:false

引用数据类型 : string               默认值:null

 1 class Demo05 {
 2         byte a;
 3         int b;
 4         short c;
 5         long d;
 6         float e;
 7         double f;
 8         char g;
 9         String h;
10         
11     public static void main(String[] args) {
12         Demo05 var = new Demo05();
13         System.out.println(var.a);
14         System.out.println(var.b);
15         System.out.println(var.c);
16         System.out.println(var.d);
17         System.out.println(var.e);
18         System.out.println(var.f);
19         System.out.println(var.g);
20         System.out.println(var.h);
21 
22     }
23     
24 }

 注意:要把char放最后,要不会有不显示

 

整   型默认  是  int

浮点型默认  是 double

原文地址:https://www.cnblogs.com/sunmoonyou/p/9309423.html