012-Four access permission modifiers

Disclaimer: All my articles are the compilation of online teaching videos, including Mad God Talk, Shang Silicon Valley, Dark Horse Programmer, etc., used as reference materials, without any commercial use, please refer to the majority of netizens, please do not spray ,Thank you. (Note that due to the website, some code characters may have problems. It is recommended that when reading the code, it is best to correspond with the picture below)
Java permission modifiers public, protected, (default), private are placed in the class Before the member is defined, it is used to limit the access authority of the object to the member of the class.
012-Four access permission modifiers
Only public and default (default) can be used to modify class permissions. Among them, the public class can be accessed anywhere, while the default class can only be accessed by classes within the same package.
Example:
012-Four access permission modifiers
012-Four access permission modifiers

Access control analysis

012-Four access permission modifiers

Guess you like

Origin blog.51cto.com/12859164/2547240