Array variable “might not have been initialized”

后端 未结 2 591
别那么骄傲
别那么骄傲 2021-01-05 22:11

I get the error:

TestCounter.java:115: variable counters might not have been initialized counters[i] = new Counter(i);

2条回答
  •  醉梦人生
    2021-01-05 23:11

    You haven't created the array, you've just declared the variable.

    You need to do this:

    Counter[] counters = new Counter[30];
    

    or something similar

提交回复
热议问题