Why does this Java code compile?

前端 未结 14 2050
情深已故
情深已故 2021-01-30 01:24

In method or class scope, the line below compiles (with warning):

int x = x = 1;

In class scope, where variables get their default valu

14条回答
  •  鱼传尺愫
    2021-01-30 02:03

    Complier read statements from right to left and we designed to do the opposite. That's why it annoyed at first. Make this a habbit to read statements (code) from right to left you won't have such problem.

提交回复
热议问题