Set uniques = new HashSet();
Set dups = new HashSet();
for (int i=0; i<args.length; i++)
if (!uniques.add(args[i]))
dups.add(args[i]);
uniques.removeAll(dups); // Destructive set-difference
System.out.println("Unique words: " + uniques);
System.out.println("Duplicate words: " + dups);