What is the /= operator in Java?

assignment-operator, java

Solution

It's a combination division-plus-assignment operator.

a /= b;

means divide `a` by `b` and put the result in `a`.

There are similar operators for addition, subtraction, and multiplication: `+=`, `-=` and `*=`.

`%=` will do modulus.

`>>=` and `<<=` will do bit shifting.

Problem

The following code sample prints `1.5`. ``` float a = 3; float b = 2; a /= b; System.out.println(a); ``` I don't understand what the `/=` operator does. What is it supposed to represent?

Original source