我真的需要帮助修复我的这行代码,我不断收到这两个错误:
第一个错误:需要数组,但找到了字符串 if(x.length() == 0 && y.length() > 0 && y[0] == "*")
第二个错误:没有找到合适的方法来替换(int,int) String newY = y.replace(0,1); 任何帮助将不胜感激
//Second string is empty and there is wildCard character
if(y.length() == 0 && wildCard)
{
return true;
}
if(x.length() == 0 && y.length() > 0 && y[0] == "*")
{
String newY = y.replace(0,1);
return match(x, newY, true);
}
最佳答案
y[0] 用于数组;使用 y.charAt(0) 作为字符串。此外,将其与“”(字符)进行比较,而不是与另一个字符串“”进行比较。
关于Java递归构建错误: array required,但找到字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15724419/