I'm new to Java, and am having trouble understanding why the if/else statement in this code seems to believe the strings a
and c
are not equal.
public class Main {
public static void main(String[] args) {
String a = "foo";
String b = "Foo";
String c = b.toLowerCase();
System.out.println(c);
if (a == c) {
System.out.println("Strings are equal");
}
else {
System.out.println("Strings are NOT equal");
}
}
}
Here is the output:
foo
Strings are NOT equal
I'm using www.learnjava.org and their webservice to compile/execute code, if that matters.
Thanks