-2
定義爲a
變量在if
循環中並且需要傳遞在else if
循環中更新的值。例如:從java中傳遞變量if到else
if(document.getVersionIdentifier().getValue().equals("00"))
{
String a=attrs.put(CREATED_BY, shortenFullName(document
.getCreatorFullName()));
// Value a = USer1
}
else if(document.getVersionIdentifier().getValue().equals("01"))
{
String b = attrs.put(document,a);
// Need value of b to be User1
}
請注意,代碼沒有任何意義,如寫入;如果第一個'if'被執行,第二個不會被執行,除非getVersionIdentifier()。getValue()'在被調用兩次時能夠返回不同的值。所以'a'永遠不能是'null'以外的任何東西。所以這絕對需要調整。 – ajb
同意。增加了更多的代碼文檔以使其清晰。 –