300+ free video programming tutorials ― Learn for free!

Java Tutorial - #31 - StringBuffer

Category: Java - Author: Karl Hadwen

Home > Java > Java Tutorial - #31 - StringBuffer

Did you find this video helpful? If so, why not subscribe!? ? http://bit.ly/CognitiveSurge

In this video I'll be showing you use StringBuffer.

To quote the Java docs: A thread-safe, mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.

String buffers 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.

The principal operations on a StringBuffer are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string buffer. The append method always adds these characters at the end of the buffer; the insert method adds the characters at a specified point.

Like the Cognitive Surge Facebook page
https://www.facebook.com/cognitivesurge

Follow me on Twitter (Feel free to tweet me questions!)
https://twitter.com/karlhadwen