Why does this Java code with “+ +” compile?

It is the unary plus, twice. It is not a prefix increment because there is a space. Java does consider whitespace under many circumstances.

The unary plus basically does nothing, it just promotes the operand.

For example, this doesn’t compile, because the unary plus causes the byte to be promoted to int:

byte b = 0;
b = +b; // doesn't compile

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)