Skip to main content

Practice ยท 3 of 3

hashCode/equals in action

Inside Solution, write static java.util.HashSet<String> dedupe(java.util.List<String> words) returning a HashSet of the distinct words. Then write record Slug(String raw) whose compact constructor lowercases and trims the raw value โ€” so that new Slug(" A ") equals new Slug("a") and both collapse to one entry in a HashSet.

Difficulty: beginner

Back to lesson: Practice: Practice: Modeling Data