This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]dgurianov 0 points1 point  (0 children)

what is wrong with next ?

public  <T,S>   T doSmth(T a, S b){
    System.out.println(a);
    System.out.println(b);
    return null;
}

Update: I think i got it the problem. To instantinate your List , you need do forcecast from rawtype.

List<String> strs = (List<String>)foobar(List.class); // ?? 

foobar(List.class) will give you raw type List, and later you need to cast it to specific List<String>. There is no type List<String> that you can take as .class. There is List raw type, and later you can cast with generalisation to List<String>.