Java string concatenation - is there a better way? -
Just a quick form question is a better way to insert stars in the following code (i.e. instead of adding it Can I set tmpError just like a new string?)
Validate the public null () Exceptions thrown {string tmpError = ""; If (absolute == faucet) tmpError = tmpError + "did not set the absolute"; If (Permanenti == blank) tmpError = tmpError + "the parametric was not set"; If (paramC == null) tmpError = tmpError + "paramC was not set"; If (! TmpError.equalsIgnoreCase ("")) {tmpError = "Error occurred" + tmpError; Throw a new exception (tmpError); }} Thanks in advance
I would always recommend StringBuilder Usage
Something like this:
Validate public null () throws exception {StringBuilder error = new StringBuilder (); If (absolute == faucet) error .append ("Parama was not set"); If (paramB == zero) error.append ("paramB was not set"); If (paramC == null) error.append ("paramc was not set"); If (error.length ()> gt; {} throw new exception ("error occurred" + error .ststring ()); }}
Comments
Post a Comment