Is there any magic hanging anywhere that could mean that
(object0 == object1) != (object0.equals(object1))
where object0 and object1 are defined types that have not redefined Object.equals ()?
No. This is exactly the definition of Object. equals () .
... this method returns true if and only if x and y refer to the same object (x == y is true) ...
public boolean equals( Object o ) { return this == o; }
Yes, if the type object0does not redefine Object.equals()"you mean a specific type, not a superclass.
object0
Object.equals()
object0 object1 B, B A, A equals(Object obj), B , , B equals(Object obj), (object0 == object1) != (object0.equals(object1)).
object1
equals(Object obj)
, object0 == null object1 == null, true, - NullPointerException;-) , .
equals(), , equals()...
eclipse: object.java control-o. "equals" , "equals": equals
Object.java src equals :
return (this == obj)
: -)
Yes, null == nulltrue, but null.equals(null)not defined.
null == null
null.equals(null)
No, if equals()not overridden, it returns true if the objects are the same identical objects in memory.
equals()
No. The actual object class 0 (not necessarily a declared variable type) must have overridden equals (). Try printing object0.getClass ().
Here is the source code for Object.equals:
public boolean equals(Object obj) { 151 return (this == obj); 152 } 153
So, no.