Hi,
Can anyone explain why the both the 'if' conditions fail.
String s = "abcde";
StringBuffer s1 = new StringBuffer("abcde");
if(s.equals(s1))
s1=null;
if(s1.equals(s))
s=null;
I beleive that s and s1 are two distinct objects and to compare their string values, equals() will be the right method. This fails here, howcome ? After looking at the Sun API, StringBuffer inherits the equals method from Object which actually only compares the address (==) and not the string values inside. But again, am I not calling the equals method in my first condition from a string and not a stringbuffer. Where am I making a mistake?
Besides this, correct me if I am mistaken, IO is excluded for the 1.4 exam,right.
Thanks
Sandeep