GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java StringBuffer Class
Selected Reading
Java StringBuffer ClassStringBuffer Class IntroductionThe Java StringBuffer class is mutable sequence of characters. StringBuffer can be used to modify the content of a String with ease. It provides many utility functions to manipulate a string. A StringBuffer opearations are syncronized in nature and it is recommanded to be used in multi-threading environment. In case, syncronization is not needed, we can go for an alternate API StringBuffer. StringBuffer Class DeclarationFollowing is the declaration for java.lang.StringBuffer class − public final class StringBuffer
extends Object
implements Serializable, CharSequence
StringBuffer Class ConstructorsFollowing is the list of constructors of the StringBuffer class.
StringBuffer Class methodsFollowing is the list of methods of the StringBuffer class. Each method is having multiple examples to demonstrate the functionality of the method.
Methods inheritedThis class inherits methods from the following classes −
Example: Append a Boolean to the StringBufferThe following example shows the usage of Java StringBuffer append(Boolean b) method. Here, we are instantiating a StringBuffer object "buff" with the string name "tuts". Then, we invoke the append() method using the "buff" object with a boolean argument "true". The return value will be the appended string name "tuts true". Similarly, we demonstrate another case using the string name "abcd" and a boolean argument "false". package com.tutorialspoint;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer stringBuffer = new StringBuffer("tuts ");
System.out.println("buffer = " + stringBuffer);
// appends the boolean argument as string to the string stringBuffer
stringBuffer.append(true);
// print the string stringBuffer after appending
System.out.println("After append = " + stringBuffer);
stringBuffer = new StringBuffer("abcd ");
System.out.println("stringBuffer = " + stringBuffer);
// appends the boolean argument as string to the string stringBuffer
stringBuffer.append(false);
// print the string stringBuffer after appending
System.out.println("After append = " + stringBuffer);
}
}
OutputLet us compile and run the above program, this will produce the following result − buffer = tuts After append = tuts true stringBuffer = abcd After append = abcd false Advertisements
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |