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

后端 未结 5 1210
-上瘾入骨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:17

    If you want to initialize the test and test2 variables you should do so at the point of declaration.

    boolean test = true;
    int test2 = 3;
    

    The { and } you have added make an initializer block which avoids the error. It's a bit of an odd way to do things, so I'd always prefer to see variables initialized at the point of declaration if that's possible!

提交回复
热议问题