File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Cattle Drive and the fly likes What is an accumulator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "What is an accumulator" Watch "What is an accumulator" New topic

What is an accumulator

Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

I have a question. I have these two local attributes....
int number1 = 0;
int number2 = 2;
Someone asked me to use an accumulator but i am not sure what it means. I tried to look it up but no luck.
I could use an array or int number1, number2.

Does anyone have an opinion about an 'accumulator'?

Thank you,

star chaser..
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1789

Uhmmm.... not sure what the context is.... I haven't heard of an accumulator.....

I wonder if it's like a counter class?

Somewhere near the end of this thread I found out about counter classes.

Also, Google "counter class" java and see if it might work for what you're doing.

I could be totally off base here.

When you do things right, people won't be sure you've done anything at all.
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

It will be nice to use some type of map but i think it is simple enough to eliminate that option.

int something()
int number1 = 0;
int number2 = 0;


return number1 and number2;

I can't think of something else to use other than an array. hmm
paul wheaton

Joined: Dec 14, 1998
Posts: 20917

int x = 0;

... do stuff ...

if (too many pancakes)
x+= 7;

... do stuff ...

x += 2;

... do stuff ...

while (the tide is high)


x is an accumulator. It accumulates.

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 161

thats a nice, clever trick.

thank you!
I agree. Here's the link:
subject: What is an accumulator
It's not a secret anymore!