[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Back to Conditionals (1). On to Conditionals (3).
Held: Tuesday, February 15, 2005
Summary: Today we continue our basic exploration of conditionals.
Overview:
Notes:
Overview:
standardcomparison methods,
equals(Object other) and compareTo(Object other)
equals method returns true if other is naturally the same asthe current object.
naturally the same asvary from class to class.
compareTo method returns a negative integer if the current object is less than other, 0 if the two are naturally the same, and a positive number if the current object is greater than other.
instanceof operation.
public boolean equals(Object other)
{
if (other instanceof Fraction) {
Fraction f = (Fraction) other;
return (this.numerator.equals(f.numerator))
&& (this.denominator.equals(f.denominator));
}
else {
// Can only compare to other fractions.
return false;
}
} // equals(Object)
Back to Conditionals (1). On to Conditionals (3).
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed May 11 10:55:51 2005.
The source to the document was last modified on Mon Jan 24 10:17:06 2005.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2005S/Outlines/outline.14.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby