Best Practice:  String Concatenation with Java

Technote (FAQ)
Problem
Solution
Exercise extra caution when choosing a technique for string concatenation in Java programs. Simply using the '+=' operator to concatenate two strings creates a large number of temporary Java objects, since the Java String object is immutable. This can lead to poor performance (higher CPU utilization) since the garbage collector has additional objects to collect. Use the Java StringBuffer object to concatenate strings because it is more efficient.
Related information
Best Practice: String Concatenation with Java












Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, General
Operating system(s): Multi-Platform
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Software edition: Edition Independent
Reference #: 1053992
IBM Group: Software Group
Modified date: 2003-05-29