• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

JavaBeans

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody:

I have recently started studying for the SCJP exam. The first chapter of the book I am using talks about JavaBean conventions, specifically for providing getters and setters for all private instance data (properties). Do you have to provide getters AND setters for all properties. The reason I ask is that I came across the following code on another site and they call it a bean:



Notice that they don't provide getters and setters for all their properties. Is this a bean?

thx,
Tim
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not a java bean.

Sun has set some naming convention for java bean

1. For bean property x, method should be setX, getX. For boolean field, you can use getX or isX.

2. For listener, method signature should be addX and removeX.

Your bean does not define setters/getters even for a single field. If you execute this bean on say bean development kit popularly known as BDK, you can't get the value of dirname which you have set by setter. Because there is no getter for that.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!