Question: Java Programming Define a class named Point with 2 data fields x and y. 1. Implement the comparable interface for comparing the points on x-
Java Programming
Define a class named Point with 2 data fields x and y.
1. Implement the comparable interface for comparing the points on x- coordinates. If two points have the same x, compare their y.
2. Implement the comparator interface for comparing the points on y- coordinates. If two points have the same y, compare their x.
3. Create an arrayList of 5 points then apply the Collections.sort Method to display the points in increasing order of their x-coordinates then in increasing order of their y-coordinates.
4. Same question as 3. But using an array (class Arrays) of 5 points.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
