list.java
来自「JAVA图形用户界面设计与实例+(源代码)」· Java 代码 · 共 45 行
JAVA
45 行
//List.java//Linked list class, holds URL informationpublic abstract class List { protected WebNode head; protected int size = 0; public List() { head = null; } public void remove(String s) throws Exception {//Remove URL } public void add(String url) {//AddURL WebNode placeHolder = new WebNode(); placeHolder.setURL(url); placeHolder.setNext(head); head=placeHolder; size++; } public String getName(int i) throws Exception{//Returns the name of a URL WebNode wn = head; if (isEmpty()) throw new Exception("记录为空"); for (int x = 0; x < i; x++) {//查找下一个URL,并且返回其值 wn = wn.getNext(); } return wn.getURL(); } public int getSize() {return size;}//ListSize public boolean isEmpty() { return (head == null); }//the list is empty or not}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?