Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Uuuh, I was so close. :-) I tried the same, but with L implements List. Commented Feb 27, 2015 at 14:23
  • Well, this gets me Type safety: The expression of type List needs unchecked conversion to conform to List<Long> now, when I call doSafeCast(). :-D Commented Feb 27, 2015 at 14:31
  • This is the best you can do, actually, because at Runtime you can't specify the generic-parameter for the class you want to instantiate. Commented Feb 27, 2015 at 14:40
  • All right, so that makes the overall idea pretty useless, if I end up having a type safety warning again. Commented Feb 27, 2015 at 14:50