News for hackers. Stuff that matters.
Re:Background: how we got the generics we have (2020) by zeroimpl on Friday April 02, 2021 @06:02PM (#26676435)
Fun fact - if you don’t like Java erasing types by default, you can just pass them along manually yourself.

There’s a bunch of ways to do this, but I’ll just leave this one trick here.

Instead of:

    List<Integer> x = new ArrayList<Integer>();
write this:

    List<Integer> x = new ArrayList<Integer>(){};
Now you’ll be able to ask at runtime and determine it is a subclass of List<Integer>.

There are no comments on this comment yet.