/*
My question is not regrading to equals or == when i compile and run following code
it shows output
S1 equals S2 true
false where is S1==S2
string goes it should display following output
S1 equals S2 true
S1 == S2 false if i uncommented line 8 and then compile following error occurs
Incompatible type for boolean. Can't convert boolean to java.lang.String.
System.out.println(s3==s4+"S1 == S2 "+s1==s2); //line 8
^
what im thinking in second case it first evalute and execute first ==
state ment then try to compare boolean value with String i.e s2
is compare against result of s3==s4 .
but whatever case problem is that it is ignoring String in" "
pls help me
*/
class Com{
public static void main(String args[]){
String s1=new String("Hello");
String s2="Hello";
String s4="Hello";
String s3="Hello";
System.out.println("S1 equals S2 "+s1.equals(s2));
System.out.println("S1 == S2 "+s1==s2);
//System.out.println(s3==s4+"S1 == S2 "+s1==s2); //line 8
}
}