Java方法命名约定
我在Bean类中有一个布尔字段,称为showlabels
,我想为其提供getter和setter方法。设置器将为setShowLabels
,但应为iSshowinglabels
,isshowlabels
(这真的很奇怪)或setsshowlabels
?
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
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来可能很奇怪,
isShowLabels
,这是惯例。您始终可以将布尔值重命名为showingLabels
。It should be
isShowLabels
weird as that may sound, that's the convention. You could always rename the boolean toshowingLabels
.