Why is it not legal to have the following two methods in the same class?
class Test{ void add(Set ii){} void add(Set ss){}
The problem is that Set and Set are actually treated as a Set from the JVM. Selecting a type for the Set (String or Integer in your case) is only syntactic sugar used by the compiler. The JVM can't distinguish between Set and Set.
Set