这是我的代码。当我打印字符串cmd时,它打印出“打印”,但是,如果statemnet仍然不能运行。这里是我的代码:Java string.equals if statement not working
public static void main(String[] args) throws InterruptedException {
String url = "http://xboxfl.co/java/inc/command.txt";
String cmd = Methods.getContents(url, "UTF-8");
System.out.println(cmd);
if(cmd.equalsIgnoreCase("print")){
System.out.println("it works");
}
}
希望有人可以提供帮助。谢谢!
如果将cmd更改为cmd =“print”,它可以正常工作,什么是方法?你能否提供methods.getContents的代码) – Mark
什么是'Methods.getContents'?那是哪里? – Coffee
如果你运行上面的src,你的代码的输出是什么? – Jayamohan