A Class Implements the Comparable Interface
From Java Example Source Code
Contents |
[edit] Overview - A Class Implements the Comparable Interface
This is a Java example program.
[edit] Java Source Code
- Package: example.comparator
- File: Time.java
package example.comparator;
public class Time implements Comparable {
private int hour, minute;
public Time(int hh, int mm) {
this.hour = hh;
this.minute = mm;
}public int compareTo(Object o) {
Time t = (Time) o;
return hour != t.hour ? hour - t.hour : minute - t.minute;
}public boolean equals(Object o) {
Time t = (Time) o;
return hour == t.hour && minute == t.minute;
}public int hashCode() {
return 60 * hour + minute;
}}
[edit] What Result You Can Get
Coming soon...
[edit] Required External Libraries and/or Files for this Java Example
Need nothing.
http://www.ase2009.com/ online casino 132 http://www.hellzyea.com/health health insurance 8DDD http://www.yourautoinsurancesite.com/ auto insurance quotes 135811 http://www.makemeasammich.com/ auto insurance mcnxu
[edit] Question & Answer
Any question?
Click edit and post your question or answer here.
