Perennially Sane

Reply to comment

Casting big collections to String

2 comments

A word of warning: If you are working with Collections in Java that are over 5000 records, do not implement a toString that aggregates them all as text. String concatenation is obscenely slow in that context, which means you will wait several minutes for data sets that are larger. Presumably this is dependent on String length as well as record count, so it also matters how big the text of each record is.

Workaround? Use void print() instead of String toString(). Admittedly, it's not as flexible, but it's orders of magnitude faster.

And that's what I have learned for today.

Reply

The content of this field is kept private and will not be shown publicly.
  • You may use these tags: [abbr], [acronym], [b], [center], [code], [color], [cpp], [css], [define], [diff], [dtd], [font], [h3], [h4], [h5], [h6], [hr], [html], [i], [img], [java], [javascript], [justify], [left], [list], [mysql], [node], [ol], [perl], [php], [python], [quote], [right], [s], [sh], [size], [sql], [sub], [sup], [table], [u], [ul], [url], [wikipedia], [xml]
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Easily link to terms in various wikis. For help, see <a href="/interwiki/3">interwiki</a>.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Powered by Drupal, an open source content management system

eXTReMe Tracker