[JAVA] About private public

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

イラスト7 31.png

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

About private public
Ruby public protected private
Java encapsulation private public
A private note about AtomicReference
About =
About method.invoke
About Kotlin
About attr_accessor
About Hinemos
About inheritance
About params
About Docker
About form_for
About Spring ③
About polymorphism
About Optional
About hashes
About JitPack
About Dockerfile
About this ()
About devise
About encapsulation
About Docker
About JAVA_HOME
About active_hash
About static
About exceptions
private method
About scope
[Maven] About Maven