beyondgrader.com Logo
DemoBrowseAboutTeamLogin

List Unique Items

Geoffrey Challen // 2021.9.0

Create a class Unique that provides a single class method uniqueItems. uniqueItems accepts a list of Objects and returns a count of how many of the objects in the list are unique, meaning that there are no other objects in the list that are equal to them. No items in the list will be null.

For example, given the list {1, 2, 4} you would return 3, whereas given the list {2, 2, 5} you would return 1. The list may contain any kind of Object. You may import collections like Maps or Sets for this problem, but they are not required.