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.
|
Output of the program:
| C:\unique>javac StringBufferExample.java C:\unique>java StringBufferExample strBuffer1 : Bonjour strBuffer2 capacity : 60 strBuffer3 capacity : 16 C:\unique> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Creation of StringBuffer View All Comments
Post your Comment