Peter C
Peter C

Reputation: 6307

Java method naming conventions

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?

Upvotes: 3

Views: 851

Answers (1)

Adam
Adam

Reputation: 44929

It should be isShowLabels weird as that may sound, that's the convention. You could always rename the boolean to showingLabels.

Upvotes: 9

Related Questions