Question: (USE INHERITANCE extends/implements) Part 2 Inheritance, comparable and comparator Part A: Point.java Write a Point class that simulates a 1D point, which has an x
(USE INHERITANCE extends/implements)
Part 2 Inheritance, comparable and comparator Part A: Point.java Write a Point class that simulates a 1D point, which has an x coordinate value. Implement the constructors (both default and overloading), get method, and default toString method.
Part B: Test.java Generate a Point array1 of five 1D points, (1.1, 2.2, 0, 7, 1.1) Sort the 1D point array using the Arrays.sort method by passing your own comparator using anonymous inner class style. 1D points are compared based on their x coordinates. (Print the array after sorting) After, Sort the 1D point array again in reverse order by pass a slightly different comparator using lambda expression style. (Print the array after sorting.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
