首页 > 代码库 > Singly linked list algorithm implemented by Java

Singly linked list algorithm implemented by Java

Jeff Lee blog:   http://www.cnblogs.com/Alandre/  (泥沙砖瓦浆木匠),retain the url when reproduced ! Thanks

 

Linked list is a normal data structure.here I show how to implements it.

Step 1. Define a structure

public class ListNode{	public ListNode Next;	public int Value;	public ListNode(int NewValue)	{		Value = http://www.mamicode.com/NewValue;>

Step 2. implements the functions

public class Clist{	private ListNode Head;	private ListNode Tail;	private ListNode Current;	private int ListCountValue;		public Clist()	{		ListCountValue = http://www.mamicode.com/0;>

Step 3. Test class for testing

public class Test{	public static void main(String[] args)	{		Clist clist = new Clist();		clist.Append(12);		clist.Append(22);		clist.Insert(66);		clist.Insert(33);		clist.Delete();		clist.printAllListNode();	}}

 

we will see:

12226633

Singly linked list algorithm implemented by Java