这里是代码摘录。
while(true) {
System.out.print("Enter New Command: ");
Scanner scan = new Scanner(System.in);
String myLine = scan.nextLine(); //finds out whether command is to add,find, or delete
String[] splitInfo = myLine.split(" ");
if (myLine[0].equals("find")) { //*****ERROR********
d.find(myLine[1]); //*****ERROR HERE******
}
我记下了我的错误发生在哪些行。 我做错了什么以及我应该如何解决它?
最佳答案
myLine
是您的字符串,splitInfo
是您的数组。你必须改变
if (myLine[0].equals("find")) {
d.find(myLine[1]);
}
至
if (splitInfo[0].equals("find")) {
d.find(splitInfo[1]);
}
关于java - 如何修复大学目录的服务器类中的此 "error: array required, but String found"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29880574/