[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Back to Laboratory: Java Basics, Continued. On to Reuse through Inheritance.
Held: Wednesday, 22 September 2004
Summary: Today we visit some of the standard methods that most of your model classes should use.
Related Pages:
Due
Assignments
Notes:
Overview:
toString
.
equals
, which you use to determine whether one object is "naturally" the same as another object.
equals
method is
public boolean equals(Object other)
Vec2D ovec = (Vec2D) other;
instanceof
operation
if (other instanceof Vec2D) { Vec2D ovec = (Vec2D) other; ... } else { return false; }
compareTo
method is a more general form of comparison.
public boolean compareTo(Object other)
compareTo
method, you should indicate that your mold class implements Comparable
.
clone
method makes another copy of the current object.
clone
method, you should indicate that your mold class implements Cloneable
.
clone
is
public Object clone()
hashCode
method returns some integer that represents this object.
hashCode
method in the second half of the semester, but I'd like you to start using it now.
Back to Laboratory: Java Basics, Continued. On to Reuse through Inheritance.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
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 Dec 8 10:37:12 2004.
The source to the document was last modified on Thu Aug 26 20:22:22 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2004F/Outlines/outline.16.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby