• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaBean name convention  RSS feed

 
Bob CHOI
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the setter methods below conform to JavaBean name convention? (Not from any mock test)

Thanks!

private int a;

1. void setA(int a) {};
2. protected void setA(int a) {};
3. public void setA(int a) {}
4. public void setA(int x) {}
 
Sandeep Rana
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think
public void setA(int a)
is the correct setter method of a bean.
You can get more info regarding this on sun website. Just search for java coding convention.
Thanks
 
Wes Misenheimer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Must be 3, since a setter must be
1-marked public
2-marked void
3-have an argument that represents the property being set.
(I don't think that "int x" represents the property "A")
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!