List vs List<Object>

前端 未结 6 844
借酒劲吻你
借酒劲吻你 2020-12-10 03:56

Why do we lose type safety when using List and not while using List? Aren\'t they basically the same thing?

EDIT

6条回答
  •  Happy的楠姐
    2020-12-10 04:48

    For purposes here, you could say they're the same thing. But presumably you almost never actually fill a List with pure instance of Object. They're Strings or something. In this example, List is technically using generics but not really taking any advantage of it. So, it loses the compile-time type checking of generics.

    提交回复
    热议问题