• Post Reply Bookmark Topic Watch Topic
  • New Topic

Max length/capacity for StringBuffer  RSS feed

 
Ray Kumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Any limits on StringBuffer ??? I mean how much data I can put a in string buffer object ???
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar P
We ain't got too many rules round these parts, but we do ask that last names not be an initial. First and middle initials are ok, but last names but be at least 2 characters long and resemble a "real" last name. Please head over here and change your name to fit our policy. Thanks!
Also, I'm going to move this to the Java Beginners forum as StringBuffer is not directly related to I/O.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no limits other than the practical limit imposed by the 32-bit implementation -- i.e., there's going to be a 32-bit integer "size" member in there, which limits the number of characters to ~ 2^31.
 
paul wheaton
Trailboss
Posts: 22554
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are limited by memory and the part of the StringBuffer object that records how long the string is, which is probably an int. So probably a couple billion characters ... but the char array takes two bytes per character and the big block of memory is probably limited to two billion bytes. So, I would guess one billion.
Just a guess.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!