what is the difference between `public class` and just `class`?

前端 未结 8 1361
说谎
说谎 2020-12-12 18:27

I have noticed that if don\'t write public before a class its works same as like a public class. I can\'t understand why so? It should show a error

8条回答
  •  余生分开走
    2020-12-12 18:56

    There must be only one public class per .java source file and the name of the file must match with this public class.

    Similar question is asked before on SO. Please find it here

提交回复
热议问题