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

Rule:  StringandStringBuffer13Checked automatically with code checker

Synopsis:Do not instantiate a StringBuffer with a char
Language:Java
Severity Level:2
Category:StringandStringBuffer


Description:
StringBuffer sb = new StringBuffer('c'); The char will be converted into int to intialize StringBuffer size.
class Foo {
  StringBuffer sb1 = new StringBuffer('c'); //Bad
  StringBuffer sb2 = new StringBuffer("c"); //Better
}