⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkedlist.java

📁 用Java实现链表存储输入数据
💻 JAVA
字号:
package work_1;

//链表实现
public class LinkedList {
	private LinkNode headNode = null;
	private LinkNode tailNode = null;
	private LinkNode currentNode = null;
	private int length = 0;

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public LinkNode getHeadNode() {
		return headNode;
	}

	public void setHeadNode(LinkNode headNode) {
		this.headNode = headNode;
	}

	public LinkNode getTailNode() {
		return tailNode;
	}

	public void setTailNode(LinkNode tailNode) {
		this.tailNode = tailNode;
	}

	public LinkNode getCurrentNode() {
		return currentNode;
	}

	public void setCurrentNode(LinkNode currentNode) {
		this.currentNode = currentNode;
	}
	//增加节点
	public void addNode(LinkNode nodeInsert) {
		if (this.getLength() == 0) {
			headNode = nodeInsert;
			currentNode = headNode;
			this.length++;
		} else {
			currentNode.setNextLinkNode(nodeInsert);
			currentNode = nodeInsert;
			this.length++;
		}
	}

	// 判断是否到终点
	public boolean hasNextNode() {
		currentNode = currentNode.getNextNode();
		if (currentNode == null) {
			return false;
		} else {
			return true;
		}
	}
	//把链表头设为当前节点
	public LinkNode resetHead() {
		currentNode = headNode;
		return currentNode;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -