Question: Suppose you are implementing the Comparable interface in a class representing a Car, where the ordering is based on the cost of the car. Write
Suppose you are implementing the Comparable interface in a class representing a Car, where the ordering is based on the cost of the car. Write a compareTo method for this class. You may assume that in the Car class there is an instance variable called price and a method called getPrice.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
