Java instance variable declare and Initialize in two statements

后端 未结 5 804
天命终不由人
天命终不由人 2020-12-04 03:38

Hi I\'m having problem with initialization in java, following code give me compile error called : expected instanceInt = 100; but already I have declared it. If these thing

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 04:35

    You need to do :

    int instanceInt = 100;
    

    If it was static you could initialize in a static block.

提交回复
热议问题