01:198:111 Lecture Notes - Lecture 24: Linear Search, Selection Sort, Insertion Sort

85 views2 pages
Verified Note

Document Summary

Sequentially looking at the values of the list one after another. Depends on what is known about the list. In a list of ints or doubles, it"s easy, the == method is sufficient. Saying you"re trying to compare two robots objects in an array. Create an equal methods to do so. What do you want to compare to determine if it is. If it passes all these tests then return true. If (other == null || ! (other instanceof robot) { If (this. id== other. id && this. color. equals(other. color)){ return true; } The first if statement is to see if the object passed into the method is actually a robot object, if it is not then it must be not be equal. Robot other = (robot)other; here i am casting the passed into object as a robot object because if i do not then i will get an error in the program. This. color. equals(other. color) is done to see if two.

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