Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Creation of StringBuffer 
 

In this section, you will learn how to create a string buffer.

 

Creation of StringBuffer

                         

In this section, you will learn how to create a string buffer. Here we have used the following StringBuffer Constructors.

StringBuffer() //Default Constructor with 16 characters set
StringBuffer(String s) //String to String Buffer
StringBuffer(int initialCapacity) //StringBuffer’s with initial Capacity 

Description of code:

As mentioned above we have taken three String buffer constructors here. One is the default with 16 characters and other two takes the String buffer and capacity of StringBuffer. Therefore we get the following output.

public class StringBufferExample{
    public static void main(String[] args) {
      StringBuffer strBuffer1 = new StringBuffer("Bonjour");      
      StringBuffer strBuffer2 = new StringBuffer(60);  
      StringBuffer strBuffer3 = new StringBuffer();  
      
      System.out.println("strBuffer1 : " +strBuffer1);
      System.out.println("strBuffer2 capacity : " +strBuffer2.capacity());
      System.out.println("strBuffer3 capacity : " +strBuffer3.capacity());
    }
}

Output of the program:

C:\unique>javac StringBufferExample.java

C:\unique>java StringBufferExample
strBuffer1 : Bonjour
strBuffer2 capacity : 60
strBuffer3 capacity : 16

C:\unique>

Download this example.

 

                         

» View all related tutorials
Related Tags: java c string method sed output find get char number int tar app character start show if index ie cte

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

hi
the code samples provided in this site is very useful to me as a beginner...i have learned a lot

Posted by ranjithaajay on Tuesday, 05.13.08 @ 15:14pm | #59704

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.