我收到此消息的次数与我在代码中使用 replaceVariables
的次数一样多。我已经添加了引用的库,但我不知道还能做什么。有人可以帮我吗?
更新:这是代码:
int k = 0;
for(Xml reg_is:fetchsite.child("site").child("regexps").children("reg"))
{
if(reg_is.string("name").contains("unique")){
if(reg_is.child("start").content()=="")
error += "\tNo prefix reg.exp. given.\n";
else
prefix = HtmlMethods.removeBreaks(replaceVariables(reg_is.child("start").content()));
if(reg_is.child("end").content()=="")
error += "\tNo suffix reg.exp. given.\n";
else
suffix = HtmlMethods.removeBreaks(replaceVariables(reg_is.child("end").content()));
}
else{
poleis[k][0]= HtmlMethods.removeBreaks(reg_is.string("name"));
poleis[k][1] = HtmlMethods.removeBreaks(replaceVariables(reg_is.child("start").content()));//ιδια δομη για ολες τις πολεις
poleis[k][2] = HtmlMethods.removeBreaks(replaceVariables(reg_is.child("end").content()));
k++;
}
}
在这一部分中,我使用 XML 来从 HTML 页面中查找我想要的数据。
最佳答案
因此,replaceVariables
需要是在同一类中声明的方法,或者需要是使用 import static
导入的静态方法。 。由于它似乎是 HtmlMethods
类的方法,我敢打赌,将以下行添加到导入中应该可以解决问题:
import static com.example.HtmlMethods.*;
您只需将com.example
替换为实际的包名称即可。另一种方法是在代码中使用 HtmlMethods.replaceVariables(x)
。
也就是说,执行 string == ""
并不是确定字符串是否等于空字符串的方法。您应该使用其中之一
if (string.equals("")) {}
或
if (string.length() == 0) {}
或
if (string.isEmpty()) {}
相反。请注意,这里的 string
应该是非 null
,否则您还需要添加 string != null
或使用 "".equals(string)
。
关于java - 该类型的方法 ReplaceVariables(String) 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2932623/