I have two methods in same class:
public static Set<Type A> valueOf (Set<Type B>)
{}
public static Set<Type A> valueOf (Set<Type B>)
{}
I am getting same erasure compile time error. How do I resolve this?
I have two methods in same class:
public static Set<Type A> valueOf (Set<Type B>)
{}
public static Set<Type A> valueOf (Set<Type B>)
{}
I am getting same erasure compile time error. How do I resolve this?
Your methods are exactly the same. The compiler won't know which one to use.
Also, in case you somehow meant
public static Set<Type A> valueOf (Set<Type A>)
{}
public static Set<Type B> valueOf (Set<Type B>)
{}
Those two methods are also the same, the type identifiers (A and B) get erased by the compiler, so they again end up having the same signature.
To undestand what's going on, substitute each <GenericSomething> with Object since that is what the compiler sees - this is what's known as type erasure. Simply put, your both methods have the same signature, namely
public static Set<Object> valueOf (Set<Object>)
{}