Question: JAVA Need help with compareTo method public class Interval implements Comparable { private final int begin; private final int end; public Interval(int begin, int end)

JAVA

Need help with compareTo method

public class Interval implements Comparable { private final int begin; private final int end; public Interval(int begin, int end) { this.begin = begin; this.end = end; } // compare first by begin time, then by end time; see the examples below: // (3, 7) < (4, 5) < (4, 6) public int compareTo(Interval o) { return 0; } public String toString() { return "(" + begin + "," + end + ")"; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!