Tutorials Point


  Java Basics
  Java Object Oriented
  Java Advanced
  Java Useful References
  Java Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Java - String Buffer append() Method


previous next AddThis Social Bookmark Button


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 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 produces following result:

Test String Buffer


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names