Forums Register Login

why getter and setter methods

+Pie Number of slices to send: Send
Every field has setter and getter methods.what is happening in this methods
+Pie Number of slices to send: Send
Wow, that was so detailed...
+Pie Number of slices to send: Send
where you set and get . tell me simply
+Pie Number of slices to send: Send
If you already know that question's answer whats the point of asking. Secondly thats pure and basic common sense. If you want to ask from a design perspective then please elaborate on the question with the suitable alternative as to what do we use and why. Your question is too vague to be answered logically.
+Pie Number of slices to send: Send
You question is not clear. Tell The Details
+Pie Number of slices to send: Send
This is not a servlet specific question. Posting such question in this forum wont attract good response.
+Pie Number of slices to send: Send
Set and get methods allow access to private fields without "exposing" those fields. They may weaken encapsulation, but that can be minimised by putting controls in the methods.That version allows no control on which values are passed, nor controls on the use of the "f" reference after it has been returned.This second version ensures the value of i is always in a permitted range, as well as testing f for something or other. In either case, it throws an Exception with a nice error message so you can see what went wrong. You will also see that the returned f is cloned, so any manipulation of the clone does not affect this object.

There are different ways of handling such problems. For example, a copy constructor may be better than cloning. Note that i is a primitive, so there is no need to copy it when it is returned.

Agree with seetharaman venkatasamy that you ought to ask more details and with Samir Kureshi that you posted in the wrong place.
Aditya Keyal and Zandis Murāns: your responses are close to the line separating fair comment from rudeness.
Pay attention! Tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 945 times.
Similar Threads
Problem assigning long values
Cannot find symbol...
Why and When to use reflections
I need help - basic stuff (I think)
Clarification for jstl <c:foreach> tag
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 02:23:13.