只是一个快速的形式问题。在下面的代码中,是否有更好的方法来连接字符串(即我可以将 tmpError 设置为等于新字符串而不是添加它吗?)
public void validate () throws Exception {
String tmpError = "";
if(paramA == null) tmpError = tmpError + "paramA was not set";
if(paramB == null) tmpError = tmpError + "paramB was not set";
if(paramC == null) tmpError = tmpError + "paramC was not set";
if(!tmpError.equalsIgnoreCase("")){
tmpError = "error occured" + tmpError;
throw new Exception(tmpError);
}
}
提前致谢