As others have answered, add returns a boolean indicating whether a has been added to the set. Its equivalent to
Set<String> s = new HashSet<String>(); for(String a:args) { if (s.contains(a)){ System.out.println("Duplicate detected:"+a); } else{ s.add(a); } } From the javadoc for the Set interface.
contains boolean contains(Object o)
Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that (o==null ? e==null :o.equals(e)).