Hi,
I got caught with this question in a mock exam.
The code is:
------
String str = "Java";
StringBuffer buffer = new StringBuffer (str);
if (str.equals(buffer))
{
System.out.println ("Both are equal");
}
else
{
System.out.println ("Both are not equal");
}
------
The correct answer is "Both are not equal". but what I thaught was, since .equals() method always checks the contents of the objects, will pass the "if" condition.
can any one help me please?
Thnks & regards