From lliao@ren.eecis.udel.edu Sun Nov 17 21:55:52 2002 Date: Sun, 17 Nov 2002 21:55:22 -0500 (EST) From: Li Liao Subject: Re: testing equality > Should we test equality for Numbers only or should we do it for Objects > as well? (case 3) Both numbers and objects. > If we have to do it for objects, then I assume that two objects are > equal if their names are the same and they are objects of > the same class. Is that correct? Two expressions are equal when they evaluate to the same object. As each object is assigned a unique id at creation, two objects are the same if they have the same id. The null expression receives special treatment. It has the special null type, which--for the purposes of typechecking--is considered to be a subtype of every object type. In other words, the null expression can be used anywhere an expression with an object type is expected except on the left-hand side of a field/method access or the right-hand side of a downcast. While null has no id, it is considered as object. Therefore, when two expressions are evaluated to "VNull", these two expressions are said to be equal. I hope this is helpful. Li