Hi,
Is it possible to do something like that?
public <T, E> T<E> method(T<E> arg) {
T<E> copy = arg.getClass().newInstance();
return copy;
}
The method should create and return generic object on the basis of parameter's type. I would like to operate on Collection<E> without worrying about actual type of collection (List, Set...).
method(new ArrayList<Something>) should return ArrayList<Something>
method(new HashSet<Something>) should return HashSet<Something>
and so on.
Cheers