[英]Generate Getters and setters without underscore (not prefix/suffix) + eclipse
我的變量是
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”>“代碼樣式”)。
在這里參考
Java代碼往往遵循camelCaseStyle,而不是c_underscore_style。 遵循現有標准通常會以各種方式幫助您(您將能夠更好地閱讀其他人的代碼,而其他人將能夠更好地閱讀您的代碼,其他“其他人”是同一語言的其他開發人員)。 此外,語言的工具往往更好(例如)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.