Thursday, 3 July 2014

append (int i)

public synchronized StringBuffer append(int i)
Appends the string representation of the int argument to this sequence.

public class StringBufferAppendInt {
    public static void main(String args[]){
        StringBuffer s1 = new StringBuffer("Value of s1 is ");
        int i = 10;
        s1.append(i);
  
        System.out.println(s1);
    }
}

Output
Value of s1 is 10



Prevoius                                                 Next                                                 Home

Wednesday, 2 July 2014

append (float f)

public synchronized StringBuffer append(float f)
Appends the string representation of the float argument to this sequence.

public class StringBufferAppendFloat {
    public static void main(String args[]){
        StringBuffer s1 = new StringBuffer("Value of s1 is ");
        float f = 10.01f;
        s1.append(f);
  
        System.out.println(s1);
    }
}

Output
Value of s1 is 10.01





Prevoius                                                 Next                                                 Home

append (double d)

public synchronized StringBuffer append(double d)
Appends the string representation of the double argument to this sequence.

class StringBufferAppendDouble{
 public static void main(String args[]){
  StringBuffer s1 = new StringBuffer("Value of s1 is ");
  double d = 10.01;
  s1.append(d);
  
  System.out.println(s1);
 }
}

Output
Value of s1 is 10.01




Prevoius                                                 Next                                                 Home

append (CharSequence s)

public synchronized StringBuffer append(CharSequence s)
Appends the specified CharSequence to this sequence. If s is null, then the four characters "null" are appended.

class StringBufferAppendCharSequence{
 public static void main(String args[]){
  StringBuffer s1 = new StringBuffer("Value of s1 is ");
  StringBuffer s2 = new StringBuffer("Value of s2 is ");
  CharSequence c1 = "wxyz";
  CharSequence c2 = null;
  
  s1.append(c1);
  s2.append(c2);
  
  System.out.println(s1);
  System.out.println(s2);
 }
}

Output
Value of s1 is wxyz
Value of s2 is null




Prevoius                                                 Next                                                 Home

append (char[] str, int offset, int len)

public synchronized StringBuffer append(char[] str, int offset, int len)
len number of Characters of the char array str, starting at index offset are appended to this string.

class StringBufferAppendCharArray1{
 public static void main(String args[]){
  StringBuffer s1 = new StringBuffer("Value of s1 is ");
  char c[] = {'c', 'h', 'a', 'r'};
  s1.append(c,0,2);
  
  System.out.println(s1);
 }
}

Output

Value of s1 is ch



Prevoius                                                 Next                                                 Home

append (char[] str)

public synchronized StringBuffer append(char[] str)
Appends the string representation of the char array argument to this sequence.

class StringBufferAppendCharArray{
 public static void main(String args[]){
  StringBuffer s1 = new StringBuffer("Value of s1 is ");
  char c[] = {'c', 'h', 'a', 'r'};
  s1.append(c);
  
  System.out.println(s1);
 }
}

Output
Value of s1 is char




Prevoius                                                 Next                                                 Home

append (char c)

public synchronized StringBuffer append(char c)
Appends the string representation of the char argument to this sequence.

class StringBufferAppendChar{
 public static void main(String args[]){
  StringBuffer s1 = new StringBuffer("Value of s1 is ");
  char c = 'c';
  s1.append(c);
  
  System.out.println(s1);
 }
}

Output
Value of s1 is c




Prevoius                                                 Next                                                 Home