Why The need for getId()
Post a Reply
|Oldest Newest Rating|
· November 1, 2016
I don't know the context of your use of these get and set methods so I will give a general reply.
The concept is known as encapsulation, or protecting your variables from direct access.
If you don't want other objects to directly change the content of the ID variable you make it private.
Then you provide a setter method to validate the supplied value before changing the variable.
The getter method provides a way to retrieve a value from a private variable.
I hope this helps. If not then provide a more specific question.
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|