E81 CSE 131 Lecture 8: Sets and Object Equality

26 views2 pages
magentarat813 and 20 others unlocked
E81 CSE 131 Full Course Notes
8
E81 CSE 131 Full Course Notes
Verified Note
8 documents

Document Summary

Can still use list functions like add and delete For primitive types, equality is simple double, int, boolean. These are equal if they have the same value. By equality of a and b, do we mean a and b are the exact same object? a and b are equal in a deeper sense of the concept (i. e. value?) Let"s look at a simple class that represents an (x, y) pair. A point (5, 10) public class point { private int x, y; All objects have the method boolean equals (object other) The default implication is simply: public boolean equals(object other) { return this == other; The above tests whether the two objects are exactly the same object. In other words, they live at the same address in the heap. But we can always override this definition and give out own meaning to equality. For a string object, this is based on whether the strings.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions