+ 3
when do we have to use "class" or "public class" ?
3 Respuestas
+ 5
class when we want to keep the access restricted to members of same package, public is accessible of other packages.Sorry my basic English.
+ 2
public means you can access the class from anywhere. if there is no class modifier, it is implicitly protected, which means it can be accessed only within the package it is declared.
so Class Person is the same as protected Class Person.
0
Public class is where public static void main() lives and has to have the same name as your file name. If you are creating objects, then "class" is what you use. This is the simplified version explanation