我的变量是
private String category_code = null;
我的 getter 和 setter 生成为
public String getCategory_code() {
return category_code;
}
public void setCategory_code(String category_code) {
this.category_code = category_code;
}
是否可以生成
public String getCategorycode() {
return category_code;
}
public void setCategorycode(String categorycode) {
this.category_code = category_code;
}
我检查了属性-->代码样式-->字段,但这仅适用于前缀和后缀。
或者我应该将变量重命名为 m_categoryCode 吗?并得到我的输出如下?
public String getCategoryCode() {
return m_categoryCode;
}
public void setCategoryCode(String categoryCode) {
m_categoryCode = categoryCode;
}
哪个更好?
最佳答案
getter 和 setter 方法的名称源自字段名称。如果您对字段使用前缀或后缀(例如 fValue、_value、val_m),则可以在“代码样式”首选项页面(“Windows”>“首选项”>“Java”>“代码样式”)中指定后缀和前缀。
引用here
关于java - 生成不带下划线的 Getter 和 setter(不是前缀/后缀)+ eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15375717/