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

Category: StringandStringBuffer

Synopsis:These rules deal with different problems that can occur with manipulation of the class String or StringBuffer.


Description:
These rules deal with different problems that can occur with manipulation of the class String or StringBuffer.

Coding Rules

NameCheckedSynopsis
StringandStringBuffer1 Checked automatically with code checker Don't use duplicate String literals; use constants instead
StringandStringBuffer2 Checked automatically with code checker Avoid instantiating String objects; this is usually unnecessary
StringandStringBuffer3 Checked automatically with code checker Avoid calling toString() on String objects; this is unnecessary
StringandStringBuffer4 Checked automatically with code checker Avoid concatenating nonliterals in a StringBuffer constructor or append()
StringandStringBuffer5 Checked automatically with code checker Using equalsIgnoreCase() is cleaner than using toUpperCase/toLowerCase().equals()
StringandStringBuffer6 Checked automatically with code checker This is an inefficient use of StringBuffer.toString; call StringBuffer.length instead
StringandStringBuffer7 Checked automatically with code checker Avoid appending characters as strings in StringBuffer.append
StringandStringBuffer8 Checked automatically with code checker Combine StringBuffer.append calls, if possible
StringandStringBuffer9 Checked automatically with code checker String.indexOf(char) is faster than String.indexOf(String)
StringandStringBuffer10 Checked automatically with code checker String.trim().length()==0 is an inefficient way to validate an empty String
StringandStringBuffer11 Checked automatically with code checker Initialize objects of StringBuffer with a proper size
StringandStringBuffer12 Checked automatically with code checker No need to call String.valueOf to append to a string
StringandStringBuffer13 Checked automatically with code checker Do not instantiate a StringBuffer with a char
StringandStringBuffer14 Checked automatically with code checker Use equals() to compare String objects