-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
47 lines (42 loc) · 914 Bytes
/
Node.java
File metadata and controls
47 lines (42 loc) · 914 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
37
38
39
40
41
42
43
44
45
46
47
public class Node
{
int item;
Node object;
void add_beginning(int num)
{
Node temp=new Node();
temp.item=num;
temp.object=null;
if(object==null)
object=temp;
else{
Node n=object;
while(n.object!=null)
n=n.object;
n.object=temp;
}
}
void delete()
{
Node n=object;
Node p=null;
while(n.object!=null)
{
p=n;
n=n.object;
}
p.object=null;
}
void show()
{
Node temp=new Node();
temp=object;
System.out.println("The Data in the Linked List:");
while(temp.object!=null)
{
System.out.print("|"+temp.item+"|->");
temp=temp.object;
}
System.out.println("|"+temp.item+"|");
}
}