Why do some claim that Java's implementation of generics is bad?

后端 未结 13 1970
挽巷
挽巷 2020-11-29 15:53

I\'ve occasionally heard that with generics, Java didn\'t get it right. (nearest reference, here)

Pardon my inexperience, but what would have made them better?

13条回答
  •  猫巷女王i
    2020-11-29 16:36

    Java doesn't enforce Generics at run time, only at compile time.

    This means that you can do interesting things like adding the wrong types to generic Collections.

提交回复
热议问题