Java: how to initialize String[]?

后端 未结 11 2186
渐次进展
渐次进展 2020-12-22 18:57

Error

% javac  StringTest.java 
StringTest.java:4: variable errorSoon might not have been initialized
        errorSoon[0] = \"Error, why?\"         


        
11条回答
  •  甜味超标
    2020-12-22 19:16

    You can use below code to initialize size and set empty value to array of Strings

    String[] row = new String[size];
    Arrays.fill(row, "");
    

提交回复
热议问题