Why does Eclipse require me to set (arbitrary) brackets in java code?

后端 未结 5 1212
-上瘾入骨i
-上瘾入骨i 2021-01-29 11:56

I am currently trying to figure out how to use Eclipse to program Escape models in java. I am quite new to Escape and Eclipse, and it has been a while since I programmed in java

5条回答
  •  一个人的身影
    2021-01-29 12:05

    public class CoordinationGame extends Scape {    
      // ...
      int test2;
      // ...
      test2 = 3;  // <- errror
    }
    

    This is illegal, we can't assign values this way in a class body. The other code was legal because you used a static initializer to init the field test2.

    The error message is pretty misleading but, honestly, that happens quite often in Java ;)

提交回复
热议问题