The add method returns a boolean indicating whether or not the add succeeded. Might be clearer with indenting:

 Set<String> s = new HashSet<String>();
 for(String a:args)
 if(!s.add(a))
 System.out.println("Duplicate detected:"+a);

The message is displayed if the add failed.