0

I always see this strange symbol § but never understand wtf means enter image description here


Also what E1, T, op means here?

From the post: Why don't Java's +=, -=, *=, /= compound assignment operators require casting?

Correct me:

T = data type

op = operator

Pablo_06
  • 35
  • 5

1 Answers1

1

"§" (U+00a7 SECTION SIGN), as its unicode name suggests, just means "section". It is used to refer to specific sections in the JLS.

E1 op= E2 is a form of "compound assignment expression". I'm sure you've seen compound assignment expressions. They are things like:

myCoolVariable += 5
foo *= bar
timeLeft -= 1

In the last example, timeLeft is E1, - is op, 1 is E2. E1 and E2 are just expressions. T, as the spec says, is specifically the type of E1. op here refers to the operator directly before the =. So mostly, your understanding is correct.

The spec is saying that an expression such as timeLeft -= 1 (assuming timeLeft is an int) is equivalent to:

timeLeft = (int)((timeLeft) - (1))

except that timeLeft is only evaluated once.

Sweeper
  • 213,210
  • 22
  • 193
  • 313