Interview Questions  

Go Back   Interview Questions > Interview Questions & Answers > Information Technology > Java > Core Java

Core Java Core Java Interview Questions, Learn by sharing Core Java Interview Questions asked in various companies, Get Career advices, Interview Procedures from Core Java experts, Post asked Core Java Interview Questions and Answers.

   

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-01-2008, 01:06 PM
Senior Member
 
Join Date: Feb 2008
Posts: 1,210
Default How to find the length and capacity of

How to find the length and capacity of a string buffer ?
Reply With Quote
  #2 (permalink)  
Old 07-22-2008, 08:20 AM
Member
 
Join Date: Jul 2008
Location: West Bengal,India
Posts: 48
Default

The following code will show the lengh and the capacity of a string buffer:-

public class strbuffer {

public static void main(String args[])
{
StringBuffer strbuff=new StringBuffer();
strbuff.append("asit kumar purohit");
System.out.println("length of the string buffer is:"+strbuff.length()+" capacity:"+strbuff.capacity());
}

}
__________________
Asit Kumar Purohit.
SRIC,IIT Kharagpur.
West Bengal,India
Mail me
Reply With Quote
Reply

Tags
core java, java, software

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On