笔记3

java变量必须先赋值再使用

未赋值就使用,会出错

public class Main {
    public static void main(String[] args) {
        int x; // 定义int类型变量x,并赋予初始值100
        System.out.println(1+x); // 打印该变量的值//variable x might not have been initialized
    }
}

posted on 2020-08-04 03:15  坚持就好  阅读(63)  评论(0编辑  收藏  举报

导航