我已经用几种不同的方法对它进行了测试.我比较的字符串s与日志文件中显示的字符串完全相同.撇号是为了确保没有空格.有谁知道发生了什么?
import java.lang.reflect.Method;
import android.util.Log;
public class Button {
public Button () {
for(Method m1:MyOtherClass.class.getMethods()) {
String s = m1.getName();
if(s == "Update") {
Log.i("result","true");
}
Log.i("test", "'" + s + "'");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我真的习惯在 C# 中使用“string”而不是“String”。我想知道我能做些什么才能在 Java 中做到这一点。
如果重要的话,我正在使用 Eclipse 的 Java EE IDE。