简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM