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){}
I bumped into this when tried to write something like:
Continuable
and
Continuable
They become for compiler the 2 definitions of
Continuable<> callAsync(Callable<> veryAsyncCode) {...}
The type erasure literally means erasing of type arguments information from generics. This is VERY annoying, but this is a limitation that will be with Java for while. For constructors case not much can be done, 2 new subclasses specialized with different parameters in constructor for example. Or use initialization methods instead... (virtual constructors?) with different names...
for similar operation methods renaming would help, like
class Test{
void addIntegers(Set ii){}
void addStrings(Set ss){}
}
Or with some more descriptive names, self-documenting for oyu cases, like addNames
and addIndexes
or such.