Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is an accumulator

 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Garry
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

logic

return number1 and number2;
}

I can't think of something else to use other than an array. hmm
 
paul wheaton
Trailboss
Pie
Posts: 21598
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int x = 0;

... do stuff ...

if (too many pancakes)
{
x+= 7;
}

... do stuff ...

x += 2;

... do stuff ...

while (the tide is high)
{
x++;
}


-----


x is an accumulator. It accumulates.




 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats a nice, clever trick.

thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic