LinkedList()实现类

import java.util.List;


public class LinkedList {

private List ls;

LinkedList() {

this.ls = new LinkedList();    //为什么这句会报错呢?LinkedList不也是List的实现类吗?


}

}


fenkapian
浏览 1602回答 3
3回答

qq_青枣工作室_0

你要 import java.util.LinkedList; ll.addFirst() 这个要写参数:ll.addFirst(new News(2,"a","s"));

qq_浓米派_0

没导包!

fenkapian

好不容易弄好了 为什么带不出addFirst(),removeFirst()这些方法?import java.util.LinkedList;import java.util.List;public class LinkedListTest { private List ll; LinkedListTest() { this.ll = new LinkedList(); } void add() { ll.add(new News(1,"u","k")); ll.add(new News(2,"m","z")); ll.add(new News(2,"a","s")); ll.addFirst()   //这句编译报错 }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java