Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

Posted By: Jack Williams     Category: Java     Views: 1781

A Java Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types.

Code for Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types in Java

publicclass JAVA_058
 {

   publicstaticvoid main(String[] args)
    {
       StringBuffer SB1=new StringBuffer("A switch in time");
       StringBuffer SB2=new StringBuffer(" saves nine");

       System.out.println("StringBuffer # 1 : " + SB1);
       System.out.println("StringBuffer # 2 : " + SB2);

       SB1.append(SB2);

       System.out.println("\nStringBuffer # 1 : " + SB1);
       System.out.println("StringBuffer # 2 : " + SB2);

       StringBuffer SB3=new StringBuffer( );

       SB3.append("\nStringBuffer # 3 : ").append(SB1).append(". \n");

       System.out.println(SB3);

       StringBuffer SB4=new StringBuffer("The number is ");

       long number=999;

       SB4.append(number);
       SB4.append(12.34);

       char[] cArray={'i','s',' ','e','x','a','c','t','l','y'};

       SB4.append(cArray,2,8);

       System.out.println("StringBuffer # 4 : " + SB4);
    }
 }
  
Share: 



Jack Williams
Jack Williams author of Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types is from Melbourne, Australia.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!