I have two program as shown below.
When i run both these program both working fine.
But the the first code have a two string when I compare it gives result "ok".
the second code also have two string but this gives result "no".Why?
class Stringimp {
public static void main(String[] args) {
String str = "ali";
String s1="ali";
if (str == s1) {
System.out.println("ok");
} else {
System.out.println("no");
}
}
}
class Stringimp {
public static void main(String[] args) {
String str = "ali";
String s1="ALI";
s1=s1.toLowerCase();
if (str == s1) {
System.out.println("ok");
} else {
System.out.println("no");
}
}
}