0
for (String a: args) if(!uniques.add(a)) dups.add(a)
uniques and dups are objects of set interface. plz someone explain how second line of code works ?
1 ответ
+ 1
A set contains unique values. The add-method adds a value to the set. If this set already contains the element, the call leaves the set unchanged and returns false.
So in the set unique (just a name :-) ) are the unique values of args. The set dups contains the duplicates.