Valid JavaBeans names for boolean getter methods
问题 I know most variable names will work with "is", such as isBlue() , but is "has" also a valid prefix, like hasProperty() ? 回答1: According to the JavaBeans specification section 8.3.2: Boolean properties In addition, for boolean properties, we allow a getter method to match the pattern: public boolean is<PropertyName>(); This " isPropertyName " method may be provided instead of a " get<PropertyName> " method, or it may be provided in addition to a " get<PropertyName> " method. In either case,