我定义了一个数组
String[] str={"afsdfs","fwfwfwf"};
.......
for(int i=2;i<=10;i++)
{
str[i]=things; //然后这里就提示Array constant can only be used in initializers
}
things是我前面定义的字符串变量
请问把数据怎么插入数组?
我定义了一个数组
String[] str={"afsdfs","fwfwfwf"};
.......
for(int i=2;i<=10;i++)
{
str[i]=things; //然后这里就提示Array constant can only be used in initializers
}
things是我前面定义的字符串变量
请问把数据怎么插入数组?
另外,String[] str={"afsdfs","fwfwfwf"};,那么str长度是2
for(int i=2;i<=10;i++)
这就不行了
String[] str={"afsdfs","fwfwfwf","","","","","","","","",""};
这样试试看