When would you not use Generic Collections?

前端 未结 8 1884
醉酒成梦
醉酒成梦 2021-01-19 00:57

The advantage of using generics is that it increases the type safety - you can only put in the correct type of thing, and you get out the correct type without requiring a ca

8条回答
  •  一个人的身影
    2021-01-19 01:41

    Type variance with generics can trip you up, but mostly you should use generic collections. There isn't a really a good reason to avoid them, and all the reason in the world to avoid un-typed collections like ArrayList.

提交回复
热议问题