i have run the following code
class MWC200
{
public static void main (
String[] args)
{
String s1 = "ABC";
StringBuffer s2 = new StringBuffer(s1);
System.out.print(s2.equals(s1) + "," + s1.equals(s2));
}
}
output is false,false
but i think it should be run time error..as string and string buffer objs cannot be compared....it should give class cast exception....if we want to compare both of them..first the string buffer should be converted to string using toString() method..and then we can compare them....and also string buffer class does not override equals method of the object class....then why this code is executing correctly....without exception.