java.lang.StringBuilder
StringBuilder class is introduced in Java 5.0 version. This class is replacement for the
existing StringBuffer class. If you look into the operations of the both the classes,
there is no difference.
also read:
- If you are using StringBuilder, no guarantee of synchronization. This is the only difference with StringBuffer class.
- It is recommended that this class be used in preference to StringBuffer as it will be faster.
- You can easily replace the exisitng StringBuffer implementaion with StringBuilder without any compilation
problem.
StringBuilderExample.java
package javabeat.net.java; /** * source : www.javabeat.net */ public class StringBuilderExample { public static void main(String[] args) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Add a string"); System.out.println(stringBuilder.toString()); }
}
Leave a Reply