java.lang Code Samples
- How do I reverse a string?
- How do I add leading zeros to a number?
- How do I split a string?
- How do I terminate a Java application?
- How do I get operating system temporary directory / folder?
- How do I get file separator symbol?
- What is Autoboxing?
- How do I copy char array to string?
- How do I convert string to char array?
- How do I calculate process elapsed time?
- How do I remove trailing white space from a string?
- How do I remove substring from StringBuilder?
- How do I decode string to integer?
- How do I get username of system current user?
Page of 6 |
Prev
|
Next
How do I append and replace content of a StringBuffer?
A StringBuffer is like a String, but can be modified. StringBuffer are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.
As of release JDK 1.5, this class has been supplemented with an equivalent class designed for use by a single thread, StringBuilder. The StringBuilder class should generally be used in preference to this one, as it supports all of the same operations but it is faster, as it performs no synchronization.
Here is our program output:
quote = an apple a quote = an apple a day quote = an apple a day keep the doctor away quote = an orange a day keep the doctor away
