+++ x unexpected type required: found variable: value

This may be a stupid question, but I have no idea why this is. I wrote the following code snippet.

public class Test {
public static void main(String... str)
{
    int y = 9;
    int z = +++y; //unexpected type required:variable found:value
    int w = +-+y; // Not Error
}}

Why does + - + y work and +++ y not?

+4
source share
2 answers

+++yinterpreted as the statement ++followed by +y.

+yit matters how -y, but the operator ++expects the variable to work (it cannot increase the value), but +yit is considered the value (the add operation was completed).

+-+y 0 + (0 - (0 + y)), , , , ( ), .

+7

Java +++ ++, +, . , +-, +-+ +, -, +.

, ~, . +, - ~, ++ --.

+3

All Articles