Java learning step-by-step private, protected, public, default modified access rights

I did Java development for a year before, and now I pick it up, learn from the basics, and record some conceptual things

private can only be accessed within this class

All classes can be accessed by public

Default decoration can only be accessed by the package where this class is located

protected protected This class's package and subclasses of other packages can access it

Let's talk about final modification

Final modified classes cannot be inherited

Final-modified methods cannot be overridden in subclasses

The final modified variable value can no longer be changed

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324155995&siteId=291194637