Java - String Buffer append() Method
Advertisements
Description
This method updates the value of the object that invoked the method. The method takes boolean, char, int, long, Strings, etc.
Syntax
Here is a separate method for each primitive data type −
public StringBuffer append(boolean b) public StringBuffer append(char c) public StringBuffer append(char[] str) public StringBuffer append(char[] str, int offset, int len) public StringBuffer append(double d) public StringBuffer append(float f) public StringBuffer append(int i) public StringBuffer append(long l) public StringBuffer append(Object obj) public StringBuffer append(StringBuffer sb) public StringBuffer append(String str)
Parameters
Here is the detail of parameters −
Here the parameter depends on what you are trying to append in the String Buffer.
Return Value
- These methods return the updated StringBuffer objects.
Example
Live Demopublic class Test { public static void main(String args[]) { StringBuffer sb = new StringBuffer("Test"); sb.append(" String Buffer"); System.out.println(sb); } }
This will produce the following result −
Output
Test String Buffer
java_strings.htm
Advertisements