why protected modifier is not allowed?

In the following code, there is an error on line 11 saying "modifier protected not allowed here". what is the reason?

Krisztian Milesz

Greenhorn

Posts: 5

posted 6 years ago

You cannot use the protected access modifier for top level classes.
The protected modifier means that the member can only be accessed within its own package or by a subclass of its class in another package.

At top level you can only use the public modifier or no modifier (package-private).