Ok, this has always baffled me, so once and for all. For objects what does == do and what does .equals() do? And could I get an example? Like Object obj1 = new Object(); and Object obj2 = new Object(); What does obj1==obj2 yeild and alternatively what does obj1.equals(obj2) yield? With strings and with wrapper clases, am I correct in saying that the == operator compares references for equality and .equals() compares values for equality? For instance Integer int1 = new Integer(1); and Integer int2 = new Integer(1); then int1==int2 will yield false and int1.equals(int2) will yeild true, correct? This is the same with strings, but StringBuffers are not overriden and so they perform the same way as the object comparison operators, correct? Also, it is obvious that with a String or a wrapper class you can compare a value or a reference, but with objects, it does not seem that there is any value to compare, so does == and .equals() in object just compare reference (meaning they do the exact same thing)? And in StringBuffer, even though there is a value to compare, does it only check reference when using .equals() or ==?
Sorry for the long runon question. I am very appreciative to anyone who can take the time to answer it.