嘚儿驾...

java 中 8 个基本数据类型的默认值

打印java中8个基本数据类型的默认值


public class Application {
    //字符型
    char flag;

    //布尔型
    boolean sex;

    /*数值型*/
    //整数类型
    byte number;

    short age;

    int workYears;

    long money;

    //浮点类型(小数类型)

    float score;

    double income;

    //打印java中8个基本数据类型的默认值
    public void printdata() {
        System.out.println("**********打印java中8个基本数据类型的默认值**********");
        System.out.println("char / flag = " + flag);
        System.out.println("boolean / sex = " + sex);
        System.out.println("byte / number = " + number);
        System.out.println("short / age = " + age);
        System.out.println("int / workYears = " + workYears);
        System.out.println("long / money = " + money);
        System.out.println("float / score = " + score);
        System.out.println("double / income = " + income);
    }


    public static void main(String[] args) {
        Application application = new Application();
        application.printdata();
    }
}

char / flag = 空

运行结果:

posted @ 2021-11-11 21:53  走马!  阅读(664)  评论(1)    收藏  举报