Worked example
String[] words = {"a", "b", "a", "c", "b", "a"};
Set<String> unique = new HashSet<String>();
for (int i = 0; i < words.length; i++) {
unique.add(words[i]);
}
System.out.println(unique.size()); // 3 — a, b, c
System.out.println(unique.contains("c")); // true
Six words go in; three distinct values come out.