-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLinkList.java
More file actions
36 lines (35 loc) · 812 Bytes
/
LinkList.java
File metadata and controls
36 lines (35 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.graph;
//1.4ÐÞ¸Ä3
public class LinkList {
public LinkNode head;
private String loc;
public LinkList(){
this.head=null;
}
public void addhead (String data){
LinkNode node=new LinkNode(data);
node.next=head;
node.data=data;
head=node;
}
public LinkNode deletehead(){
LinkNode tempNode=head;
head=tempNode.next;
return tempNode;
}
public void creatLink(String data){
LinkNode temp=head;
while(head.next!=null){
temp=temp.next;
}
temp.data=data;
}
public void displayList(){
LinkNode current =head;
while(current!=null){
current.display();
current=current.next;
}
System.out.println();
}
}