multiple classes in a single file : modifier private not allowed here

前端 未结 7 1733
暗喜
暗喜 2021-02-12 14:38

I am not able to understand why this code doesn\'t compile:

class A {
    public static void main(String[] args) {
        System.out.println(\"hi\");
    }
}

p         


        
7条回答
  •  一向
    一向 (楼主)
    2021-02-12 15:28

    B needs to be private to something. Place it within the definition of class A or create another file, B.java, and define it there, but then it cannot be private.

提交回复
热议问题