JavaBeans Naming

From Wiki
Jump to navigationJump to search

JavaBeans are Java classes that have properties.

  • Properties which are represented as private instance variables.
  • Exposed through getters and setters.


  • camel-case, prefixed with get: getPropertyName(). In case of boolean variable, prefix can also be "is".
  • should be public, return type same as that of the property, void argument.
  • e.g. public int getAge();


  • camel-case, prefixed with set: setPropertyName()
  • should be public, return type void, and argument of the same type as the property


  • Methods in the source to register events:
  • camel-case, prefix with add or remove followed by Listener Class Name, with argument as the Listener object


  • public void addXListener(XListener xl);
  • public void removeXListenerClassName(XListener xl);