Set and Get Methods in java?

Viewed 359265

How can I use the set and get methods, and why should I use them? Are they really helpful? And also can you give me examples of set and get methods?

16 Answers

Although still a second year undergraduate student I will say my opinion. I believe that Java and private variables within your class are "RULES". Therefore because the variables in your class are private I think you use getters and setters to be able to define these variables outside the class.

Related