Language syntax

Compound assignment operators

Combines a binary operation with assignment and converts the result back to the target type. The target is evaluated once. The conversion can lose information, such as a byte wrapping after +=. op= represents one concrete operator such as +=.

Formal Syntax & Structure

java syntaxjava
target op= expression

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        short count = 9;        count *= 3;        System.out.println(count);    }}
Java Reference