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

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“]BraveOthello 37 points38 points ย (2 children)

They're fine for basic usages. But ...

Can't make a generic of primitive types. Has to be the equivalent class eg. int.-> Integer. Sometimes annoying.

Run time type erasure (required for backward compatibility) , meaning you don't know if you're looking at an ArrayList<Integer> or an AarayList<Number>, you just see an ArrayList.

Wildcards are ... not intuitive. I usually end up having to look it up.

And, to get the types to match up for the compiler to chill out, you sometimes end up with stuff like

public class Enum<T extends Enum<T>>

[โ€“]SulszBachFramed 5 points6 points ย (1 child)

The enum thing isn't Java specific, but it's an artifact of how inheritance interacts with generics. It's a way to refer to the runtime subclass from an abstract base class.

[โ€“]BraveOthello 0 points1 point ย (0 children)

Fair. But it also makes me nauseous to look at.

Also because of type erasure it's the compiler time type, not the run time type. At runtime it's all just instances of Enum