
In previous releases the class StringBuffer is used to create the mutable sequence of characters. With Java 5.0 a new class is introduced to take care of mutable string. The only difference is in StringBuilder and StringBuffer is now that the methods is in StringBuilder class is not synchronized. So it is useful where the string manipulation is done by the single thread. The principle operation on a StringBuilder are the append and insert methods, which are overloaded so as to accept the data of any type.
The following example will demonstrate the use of StringBuilder Class.
package com.visualbuilder;
public class StringBuilderClassExample {
/**
* @param args
*/
public static void main(String[] args) {
StringBuilder builder = new StringBuilder();
builder.append(true);
builder.append(10);
builder.append("Visual Builder");
System.out.println(builder.toString());
}
}
Output:-
The following output will be displayed by the program.
true10Visual Builder
Java Discussion
- - Java web application
- - Difference between BMT an
- - Replace getParameterValue
- - Interviewing Next week -
- - Sudoku solver




