test.java

来自「对已建立的单链表实现插人、删除、查找等基本操作」· Java 代码 · 共 55 行

JAVA
55
字号
//import java.awt.*;
//import java.lang.*;

class Test{
	public static void main(String[] args)
	{
		LinkList L=new LinkList();

		L.add("6");
		L.add("5");
		L.add("4");
		L.add("3");
		L.add("2");
		L.add("1");
		System.out.println("The link is : ");
		L.display();
		System.out.println("-------------------------------------------");
		
		System.out.println("The length of the link is :"+L.getLength());
		System.out.println("-------------------------------------------");
		
		System.out.println("The second node is : "+L.getEntry(2));
		System.out.println("-------------------------------------------");
		
		if(L.isEmpty())      
			System.out.println("The node is  empty!");
		else
			System.out.println("The node is not empty!");
		System.out.println("-------------------------------------------");
		
		System.out.println("Add a new node 7 after the forth node : "); 
		L.add(4,"7");
		L.display();
		System.out.println("-------------------------------------------");
		
		System.out.println("Remove the fifth node : "); 
		L.remove(5);
		L.display();
		System.out.println("-------------------------------------------");
		
		System.out.println("The reverse of the link is : ");
		L.reverse();
		L.display();
		System.out.println("-------------------------------------------");
		
		System.out.println("After clearing the link : ");
		L.clear();
		L.display();
        System.out.println("-------------------------------------------");
        
		System.out.println("After clearing, the length of the link is : " + L.getLength());
		L.display();

	}
}

⌨️ 快捷键说明

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