Declaring a LinkedList in Java

前端 未结 11 2094
北荒
北荒 2021-02-20 14:26

I always learn when we declare a collection we should do, Interface ob = new Class(), if i want to use for example a LinkedList i\'ll do List ob = new LinkedL

11条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-20 14:32

    LinkedList is a generic. You should be doing:

    LinkedList linkedList = new LinkedList();
    

    (or whatever else you need to store in there instead of String)

提交回复
热议问题