Generics Puzzler
Does the following code compile?
class Puzzler {
<T> T cast(T t, Class<T> clazz) {
return clazz.cast(t);
}
<T> T nop(T t) {
return cast(t, t.getClass());
}
}Why not?
Update: To make things more interesting, in Mary's honor, I'll ship a free Google t-shirt (paid for out of my pocket) to the first person to post a comment with the correct answer (judged by me).


1 Comments:
Dammit, Chris. You win. At least I don't have to ship it. ;)
Post a Comment
<< Home