AP® Computer Science A glossary

Compound assignment operator

Also called: compound assignment

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

One of +=, -=, *=, /= and %=: it does the arithmetic with the variable and the right side, then stores the result in the variable.

Appears in the course and exam description (CED): 1.6.A.1

x op= y works like x = x op (y): the whole right side is evaluated first. On an int variable, /= and %= use int arithmetic.

int x = 4;
x *= 2 + 3;
System.out.println(x);

Output:

20
Learn it properly, with a checkpoint 1.6 Compound Assignment Operators

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure