我试图将 storyList 数组中的每个“ADJEKTIVER”字符串变成我的 adjectivesList 数组中的随机字符串。当我尝试编译时,我只收到错误:找不到符号变量。以 .length 作为变量/属性。一直在寻找解决方案
ArrayList<String> storyList = new ArrayList<String>();
storyList = reader.getWordsInFile(storyFilename);
ArrayList<String> adjectivesList = new ArrayList<String>();
adjectivesList = reader.getWordsInFile(adjectivesFilename);
for (int index =0; index < storyList.length; index++)
{
storyList[index] = storyList[index].replace("ADJEKTIV", adjectivesList[random.nextInt(adjectivesList)]);
}
writer.write(adjectivesList, outputFilename);
最佳答案
使用storyList.size()
方法而不是storyList.length
for (int index =0; index < storyList.size(); index++)
关于java - 错误 : cannot find symbol- variable. 引用 ".length",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33084232/