permaculture playing cards
The moose likes Beginning Java and the fly likes beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "beans" Watch "beans" New topic


Robert Darling
Ranch Hand

Joined: Jun 21, 2008
Posts: 100


if i have a property in a class called _celcius will the getter and setter properties be getCelcius or get_celcius ?

Kind Regards,

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

The variable name is irrelevant to the JavaBeans conventions; it's only the name of the methods that count. If the method is named getFoo(), then the bean property is named "foo", even if the variable the method returns is named "bob".

A method named "get_celsius()" would not count as a JavaBeans property accessor; it doesn't follow the naming convention.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: beans
It's not a secret anymore!