List vs List<Object>

前端 未结 6 857
借酒劲吻你
借酒劲吻你 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条回答
  •  天涯浪人
    2020-12-10 04:50

    List is a list of some type you don't know. It could be a List, List, etc.
    It's effectively equivalent to List, or List, except that it doesn't document that fact. It's only supported for backwards compatibility.

    List is a list of Objects. Any object of any type can be put inside it, contrary to a List, for example, which only accepts strings.

    So no, they're not the same thing.

    提交回复
    热议问题