posted 15 years ago
do you always need all the sums of all the variables? or are there times when you only need the 'Y' sums?
if it's an all-or-nothing, you might be able to write one method that iterates over the whole array, and keeps a sum for each variable
Then throw all those into an ArrayList (or create an ArrayList initially) and return that.
If you only need ONE sum at a time...not sure there's much else you can do.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors