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

后端 未结 8 838
梦毁少年i
梦毁少年i 2020-12-10 10:25

I\'m curious why this simple program could be compiled by java using IntelliJ (Java 7).

public class Main {
    public static void main(String[] args)
    {
         


        
8条回答
  •  一生所求
    2020-12-10 11:06

    Do not confound the preincrement operator ++ and the unary operator + repeated twice.

    int e = ++10; // won't compile "invalid argument to operation ++/--"
    int e = + +10; //compile and e equals to 10
    

提交回复
热议问题