java tutorial - Java stringbuffer append() method - java programming - learn java - java basics - java for beginners



Java  stringbuffer append

Learn Java - Java tutorial - Java stringbuffer append - Java examples - Java programs

Description

The append () method — updates the value of the object that called the method. This method in Java accepts boolean, char, int, long, Strings, etc.

Syntax

Syntax method for each 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) 
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • here the parameter depends on what you are trying to add to the string buffer (StringBuffer).

Return value

  • In Java, append () returns the updated StringBuffer objects.

Sample Code

public class Test {
 public static void main(String args[]) {
      StringBuffer sb = new StringBuffer("new");
      sb.append(" StringBuffer");
      System.out.println(sb); 
   }  
}
click below button to copy the code. By - java tutorial - team

Output

new StringBuffer

Related Searches to Java stringbuffer append() method