如何遞歸地將toString方法中的所有鏈接替換爲StringBuilder for Java? eclipse中是否有這樣的插件? 例如: 替換:如何將String catenation替換爲StringBuilder追加?
return "AccountAddresses ["
+ ", corporateAddresses=" + CommonHelper.isNotNull(corporateAddresses)
+ ", corporateDeliveryMinimum=" + corporateDeliveryMinimum
+ ", depot=" + CommonHelper.isNotNull(depot)
+ ", depotDeliveryMinimum=" + depotDeliveryMinimum
+ ", preSelectedId=" + preSelectedId
+ ", residentialAddresses=" + CommonHelper.isNotNull(residentialAddresses)
+ ", residentialDeliveryMinimum=" + residentialDeliveryMinimum
+ "]";
在此:
return new StringBuilder("AccountAddresses [")
.append(", corporateAddresses=").append(CommonHelper.isNotNull(corporateAddresses))
.append(", corporateDeliveryMinimum=").append(corporateDeliveryMinimum)
.append(", depot=").append(CommonHelper.isNotNull(depot))
.append(", depotDeliveryMinimum=").append(depotDeliveryMinimum)
.append(", preSelectedId=").append(preSelectedId)
.append(", residentialAddresses=").append(CommonHelper.isNotNull(residentialAddresses))
.append(", residentialDeliveryMinimum=").append(residentialDeliveryMinimum)
.append("]").toString();
你在用什麼編程語言?那是C#還是Java?您選擇了許多您忘記指定語言的其他標籤。 – 2011-02-02 06:20:53
@Code Grey - 你可以在Eclipse中開發C#嗎?駱駝套也是贈品... ;-) – 2011-02-02 06:43:55
有沒有你想要這樣做的原因?我相信,一旦Java編譯器完成它,你的兩個代碼塊或多或少都是相同的。 – 2011-02-02 07:07:59