您好,我尝试使用以下代码将数组索引与字符串进行比较。 equals函数根本不起作用。谢谢:)
String[] a = { "apple", "guava", "lemon" };
String b = "apple";
if (a[0].equals(b)) {
System.println.out("apple");
}
您的代码将无法编译。必须使用System.out.println
而不是System.println
或System.println.out
String[] a = { "apple", "guava", "lemon" };
String b = "apple";
if (a[0].equals(b)) {
System.out.println("apple");
}