JAVA基础-内置数据类型

Java一共八种数据类型,包括六种数字类型,一种字符类型,一种布尔类型

1、byte

8位,-127~128,默认值是0

2、short

16位,-2^15~2^15-1,默认值是0

3、int

32位,-2^31~2^31-1,默认值是0

4、long

64位,-2^63~2^63-1,默认值是0L

5、float

单精度,32位,默认值,0.0f

6、double

双精度,64位,默认值,0.0d

7、char

16 位 Unicode 字符;最小值是\u0000(十进制等效值为 0);最大值是\uffff(即为 65535);

8、boolean

true 和 false,默认值是false

9、void

JAVA中还存在另外一种基本类型 void,它也有对应的包装类 java.lang.Void
public class Test {
    static boolean bool;
    static byte by;
    static char ch;
    static double d;
    static float f;
    static int i;
    static long l;
    static short sh;
    static String str;
 
    public static void main(String[] args) {
        System.out.println("Bool :" + bool);
        System.out.println("Byte :" + by);
        System.out.println("Character:" + ch);
        System.out.println("Double :" + d);
        System.out.println("Float :" + f);
        System.out.println("Integer :" + i);
        System.out.println("Long :" + l);
        System.out.println("Short :" + sh);
        System.out.println("String :" + str);
    }
}

 

 

posted @ 2021-09-15 17:47  r1-12king  阅读(63)  评论(0编辑  收藏  举报