TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  StringandStringBuffer4Checked automatically with code checker

Synopsis:Avoid concatenating nonliterals in a StringBuffer constructor or append()
Language:Java
Severity Level:3
Category:StringandStringBuffer


Description:
Avoid concatenating non literals in a StringBuffer constructor or append().
public class Foo {
 void bar() {
  // Avoid this
  StringBuffer sb=new StringBuffer("tmp = "+System.getProperty("java.io.tmpdir"));
  // use instead something like this
  StringBuffer sb = new StringBuffer("tmp = ");
  sb.append(System.getProperty("java.io.tmpdir"));
 }
}