Java StringBuffer append values

Introduction

The append() method appends the string representation of any other type to the end of the invoking StringBuffer object.

Here are a few of its forms:

StringBuffer append(String str)  
StringBuffer append(int num)  
StringBuffer append(Object obj) 
// Demonstrate append().
public class Main {
  public static void main(String args[]) {
    String s;//from w  w  w . j  a  v  a 2  s.co m
    int a = 42;
    StringBuffer sb = new StringBuffer(40);

    s = sb.append("a = ").append(a).append("!").toString();
    System.out.println(s);
  }
}



PreviousNext

Related