Comparator vs Comparable

Report a typo

Imagine that you are developing a back-end solution for an online video game store and you have designed some domain-specific abstractions for this purpose:

class Rating {
    private int userRating;
}

class VideoGame {
    private String title;
    private List<String> keywords;
    private int copiesSold;
    private double price;
    private Rating rating;
}

class Customer {
    private String username;
    private List<VideoGame> games;
    private Map<Rating, VideoGame> reviews;
    private boolean premium;
}

Implementing the business logic, you will eventually need to compare and sort customers, video games, and ratings. Which of the available Java interfaces fits better for comparing instances of each of these classes?

Choose one option for each row
ComparableComparator
Rating
VideoGame
Customer
___

Create a free account to access the full topic