I thought I would share this. I have seen a lot of advice going around saying that it is better to use comma-delimited Strings rather than
String[]'s, that it is better to concatenate Strings by creating a temporary StringBuffer and .append() to extension String...
But I've run some tests and have found the following:
Strings use less memory than StringBuffers.
String[]'s use less memory than comma-delimited Strings.
It's better (in terms of memory) to concatenate with '+' than concat() or converting to StringBuffer and using append().
For my tests I created a number of midlets that created very large arrays of Strings or StringBuffers, and experimented with the various types of concatenation.
After all the String/StringBuffer work was done, I did a Runtime.getRuntime().gc() and wrote out the available heap memory with Runtime.getRuntime().freeMemory().
I wonder why my results suggest to do the opposite of what seems to be recommended with Strings/StringBuffers?