+ 1
Is access modifire important in Java?
4 Respuestas
+ 3
"These types of modifiers are closely related to an important part of Object Oriented Programming called encapsulation. As a reminder, encapsulation is an idea that links data with the code that manipulates it. By controlling access, you can prevent misuse.
For example, by making sure that certain variables can only be accessed through well-defined methods (the typical get/set combination of methods) we make sure that we won't encounter any unexpected values or deny outside access to certain variables/methods altogether"
As per this article:
https://stackabuse.com/access-modifiers-in-java/
+ 2
Sometimes.
They set how visible certain code is. You should expose to the user (yourself, another programmer, etc) only what they need.
Other info should remain as a hidden implementation detail, there might be no way to misuse it, but we do not want (and should not) add that noise anyway.
+ 2
Yes it is.
+ 1
That means they are used for preventing misuse of data?