Why should the compiler relate it to the Strings. What i think it is supposed to be just compare based on references ie Object.
----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
<A HREF="http://www.tipsmart.com" TARGET=_blank rel="nofollow">www.tipsmart.com</A>
I have one more code for you. I will be thankful if you please clear it out.
public class MyClass
{
public static void main(String args[]) {
StringBuffer strlit = new StringBuffer("SCJP");
StringBuffer strobj = new StringBuffer("SCJP");
System.out.println(strObj.hashCode() == strobj.hashCode());
}
} this code prints out false. It means it calls hashCode method defined in the object class. Now if you call this method on String objects it will printout true. Why this is happening
<A HREF="http://www.tipsmart.com" TARGET=_blank rel="nofollow">www.tipsmart.com</A>
Don't get me started about those stupid light bulbs. |