Class Definition
You can have multiple class files in the same source (.java) file, but only one of them may be declared public.
public class MyClass { // class definition here } class AnotherClass {}
Class Modifiers
You can add class modifiers to the declaration that changes the definition of the class.
public
This class modifier indicates that you want it to be available to classes other than just those in the package in which it is declared. That is, you'll let anybody use it. If your class does not include the public modifier, it can only be used by other classes within the same package.
final
To make your class so it cannot ever be subclassed, you include the final modifier in the class declaration. This example is from the standard API. ...
Get Java Garage now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.