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

后端 未结 13 1933
挽巷
挽巷 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条回答
  •  独厮守ぢ
    2020-11-29 16:35

    Java generics are compile-time only and are compiled into non-generic code. In C#, the actual compiled MSIL is generic. This has huge implications for performance because Java still casts during runtime. See here for more.

提交回复
热议问题