• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is the method capacity(); used??

 
Ranch Hand
Posts: 481
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class Test25{
public static void main(String a[]){
StringBuffer sb = new StringBuffer(8);
sb.append("TestString");
System.out.println(sb.capacity());/////////////////////////1
System.out.println(sb.length());
}
}
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A buffer's capacity is the number of elements it contains. The capacity of a buffer is never negative and never changes.
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you wont get to see any questioin in the real exam that test u on such merhods
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
length - number of characters stored in StringBuffer
capacity - maximum number of characters which can be stored without allocating new space. Capacity automatically increases when needed.

Length is never larger than capacity.

[ December 23, 2005: Message edited by: Vlado Zajac ]
[ December 23, 2005: Message edited by: Vlado Zajac ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic