D Dr. No macrumors regular Original poster May 4, 2005 #1 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 🙂
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 🙂
jeremy.king macrumors 603 May 4, 2005 #2 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 🙂 Click to expand... 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;
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 🙂 Click to expand... 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;
grapes911 Moderator emeritu May 4, 2005 #3 sum += term; is short for: sum = sum + term; Edit: too slow 😱