logo

Java String Buffer Append() Method


Show

Description

This method updates the worth of the entity that appealed the technique. The process takes boolean, char, int, long, Strings, etc. StringBuffer. append(boolean a) is an inherent technique in Java that is utilized to add the string symbol of the boolean row to a given series. Parameter: This technique believes a solitary parameter a of boolean type and submits to the Boolean character value to be appended.

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

public 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

Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.