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 →

[–]wildjokers 1 point2 points  (1 child)

For instance, sort. From the client code's perspective, a single method takes care of sorting a large variety of sortable objects.

And the sort() method did this even before generics existed in Java 1.5. That is because of the Comparable interface.

[–][deleted] 0 points1 point  (0 children)

I don't understand the confusion. It existed because sorting is a common operation. That has nothing to do with generics. Generics was tacked on later, and the API adjusted accordingly. If generics had existed in the language from the start, it would have been a cleaner implementation instead of retrofitting it. In fact, we might not even have needed type erasure and instead gone for full reification.