What is an access modifier? For the time being I only understood that, but I was able to learn why it exists, so I will spend it for my own review.
Difference between public and private
Why access modifiers are needed
-You can block access to variables and methods that are not accessible from the outside. Recognize ・ Easy maintenance Example: Method needs to be modified ↓ Many of them use public, so there are many functions that can be accessed. ↓ You have to make sure that all the accessible features are working properly (you need to make sure that the fix hasn't lost the original features) ↓ To prevent this from happening, set the data to private except for the essential data to narrow down the accessible range.
I think there are various other reasons, but I've taken the scope of what I understand.
Recommended Posts