Re:JDK 7 Features
by fauigerzigerk on Monday September 20, 2010 @09:23AM
(#1708670)
String interning is a side issue here. But what you suggest is basically to destructure all structured types into lots of individual arrays. That's a technique I'm using frequently. But it's a very tedious and error prone thing to do once the data structures get a little more complex. But I still agree that it's sometimes a workable solution. It's not a workable solution if Amount objects are part of other structures.
Consider this:
class Point { int x; int y; }
class Rect { Point a; Point b; }
List<Rect> list ...
1. Intern the strings.
2. Store only indexes and operate on a "main list" of currencySymbols[i] and amount[i]. (to reduce the overhead of boxed ints)
Of course this is not always possible... Every scenario has its own solution, I guess.