I have a boolean field called showLabels
in a Bean class, and I want to provide getter and setter methods for it. The setter will be setShowLabels
, but should the getter be isShowingLabels
, isShowLabels
(that's really weird sounding), or setShowLabels
?
Asked
Active
Viewed 836 times
3

Peter C
- 6,219
- 1
- 25
- 37
1 Answers
9
It should be isShowLabels
weird as that may sound, that's the convention. You could always rename the boolean to showingLabels
.

Adam
- 43,763
- 16
- 104
- 144
-
1+1, and more importantly than that it's convention, it's also *required* if you want to use classes like `Introspector`. – Kirk Woll Oct 21 '10 at 23:31
-
additionally, if using Eclipse, it can generate it for you. – NG. Oct 21 '10 at 23:31
-
Thank you. I will probably rename the field to showingLabels, and have `setShowingLabels` and `isShowingLabels`. – Peter C Oct 21 '10 at 23:36
-
@alpha123 - Glad to help! If you like the answer click the checkmark to mark it as correct. – Adam Oct 21 '10 at 23:41
-
Follow the convention, when when it sucks :-) Will save time and pain later. – Tony Ennis Oct 21 '10 at 23:45
-
@adam it said I had to wait 5 minutes. I waited, and now have. – Peter C Oct 21 '10 at 23:48