A can full of Beans (Questions)
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ok, well two
Is a bean allowed and equals and hashCode method?
Do all fields in a bean have to have both getters and setters?
I am thinking its okto have equals and hashCode, and that you may wish to represent read only properties, and thus, not having a setter is acceptable.
Cant think of a case for having a setter but not a getter.
G
Is a bean allowed and equals and hashCode method?
Do all fields in a bean have to have both getters and setters?
I am thinking its okto have equals and hashCode, and that you may wish to represent read only properties, and thus, not having a setter is acceptable.
Cant think of a case for having a setter but not a getter.
G
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Cant think of a case for having a setter but not a getter.
This example may lend you a sapling of giant orchard.
Regards,
cmbhatt
[ April 11, 2007: Message edited by: Chandra Bhatt ]
This example may lend you a sapling of giant orchard.
Regards,
cmbhatt
[ April 11, 2007: Message edited by: Chandra Bhatt ]
cmbhatt
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"Is a bean allowed and equals and hashCode method?"
Yes, a bean is just a class, just like any other class, so it can have an equals and hashCode method - in fact it might even be a good idea to provide these methods.
"Do all fields in a bean have to have both getters and setters?"
No, only the fields that you want to expose to the world outside the bean. The bean might have fields that are for internal use only. And indeed you can have read-only properties for which you only provide a getter and no setter.
Yes, a bean is just a class, just like any other class, so it can have an equals and hashCode method - in fact it might even be a good idea to provide these methods.
"Do all fields in a bean have to have both getters and setters?"
No, only the fields that you want to expose to the world outside the bean. The bean might have fields that are for internal use only. And indeed you can have read-only properties for which you only provide a getter and no setter.
Gavin Tranter
Ranch Hand
Posts: 333
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks guys,
For some reason I find beans Intimidating.
For some reason I find beans Intimidating.
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Avoid the Heinz one and you ll be fine 

ASCII silly question, Get a silly ANSI.
| I found a beautiful pie. And a tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








