Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dr. No

macrumors regular
Original poster
Sep 13, 2003
193
0
Can anyone here tell me what the Java shortcut "+=" does?

As in:

int term = 1;
int sum = 0;

sum += term;




Thanks- I am preparing for my computer science final :)
 
Dr. No said:
Can anyone here tell me what the Java shortcut "+=" does?

As in:

int term = 1;
int sum = 0;

sum += term;




Thanks- I am preparing for my computer science final :)

it adds the operand on the right to the operand on the left and reassigns the result to the left.

in your example, its the same as

sum = sum + term;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.