Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Naming conventions of get/set methods.

807588Apr 16 2009 — edited Apr 16 2009
I'm currently learning Java, and have learned that the getters and setters should be the variable name with a get or set prefix (name, getName, setName).
But, while looking at the java API, I noticed a lot of classes just use the same method name for the getter and setter, just overloaded differently (Buffer, limit() works to both set and get).

To me, that way of naming getters and setters seems a lot better. Is there a reason not to name them in that fasion?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2009
Added on Apr 16 2009
3 comments
3,909 views