I am a java beginner. This time, I will output about access modifiers.
・ Determines the accessible range for methods and variables. [Japanese translation] ** access **: Access, approach, entry and exit
① ** public **: Can be accessed from anywhere
② ** Modifier **: Only in the same package
③ ** private **: Only in the same class
④ ** protected **: Within the same package class or subclass
There is no particular pattern because public and unqualified patterns are free. ** private ** and ** protected ** are unique.
・ Private
: Used in places where access from the outside must be absolutely prevented
(Places where personal information is acquired, etc.)
It can only be accessed from the specified method.
・ Protect
: Can only be used for variables or methods
** [Referenced site] ** https://www.sejuku.net/blog/22679
Recommended Posts