解决方案 »
- Permgen OutOfMemory,请问有什么手段或者工具可以看到Permgen中被intern()的String的具体内容
- 使用java语言如何统计在服务器上的某个文件的大小(所占的磁盘空间)?
- 请问java视频的问题
- 讨论接口(interface)有什么作用.
- 求高手提示 如何使用jacob激活第二个sheet
- 如何处理java.lang.UnsatisfiedLinkError?
- 大家帮帮忙,看如何把image对象写入文件,存为一种具体的图象格式
- beginner: java的applet中,怎么让一个按钮不能使用?
- 安装jbuilder7出现如下问题
- 求大神解释一下java中的break label;用法的优缺点
- 弄的我茶饭不思的多线程理解!
- 简单socket通信问题,急~
{
private Node first = null;//链表表头
public Link()
{
this.first = null;
}
public boolean isEmpty()
{
if(this.first == null)
{
return true;
}
else
{
return false;
}
}
public void insertHeadNode(int data)
{
Node node = new Node(data);
if(this.first == null)
{
this.first = node;
}
else
{
Node tempNode = this.first;
this.first = node;
this.first.next = tempNode;
}
}
public Node deleteHeadNode()
{
if(this.first == null)
{
return null;
}
else
{
Node head = this.first;
Node next = this.first.next;
this.first = next;
head = null;
return head;
}
}
public Node findNode(Node node, int k)
{
if(this.first == null)
{
System.out.println("this link is empty!");
return null;
}
else
{
if(node.data == k)
{
return node;
}
else
{
node = node.next;
return this.findNode(node, k);
}
}
}
public void displayLink (Node node)
{
if(this.first == null)
{
System.out.println("this link is empty!");
return;
} if(node != null)
{
node.NodeDisplay();
node = node.next;
this.displayLink(node);
}
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
Link aaa = new Link();
aaa.insertHeadNode(4);
aaa.insertHeadNode(6);
aaa.insertHeadNode(8);
aaa.insertHeadNode(45);
aaa.insertHeadNode(876);
// aaa.deleteHeadNode();
aaa.displayLink(aaa.first);
Node node = aaa.findNode(aaa.first, 8);
System.out.println(node.data + " next = " + node.next.data);
}}
{
private Node first = null;//链表表头
public Link()
{
this.first = null;
}
public boolean isEmpty()
{
if(this.first == null)
{
return true;
}
else
{
return false;
}
}
public void insertHeadNode(int data)
{
Node node = new Node(data);
if(this.first == null)
{
this.first = node;
}
else
{
Node tempNode = this.first;
this.first = node;
this.first.next = tempNode;
}
}
public Node deleteHeadNode()
{
if(this.first == null)
{
return null;
}
else
{
Node head = this.first;
Node next = this.first.next;
this.first = next;
head = null;
return head;
}
}
public Node findNode(Node node, int k)
{
if(this.first == null)
{
System.out.println("this link is empty!");
return null;
}
else
{
if(node.data == k)
{
return node;
}
else
{
node = node.next;
return this.findNode(node, k);
}
}
}
public void displayLink (Node node)
{
if(this.first == null)
{
System.out.println("this link is empty!");
return;
} if(node != null)
{
node.NodeDisplay();
node = node.next;
this.displayLink(node);
}
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
Link aaa = new Link();
aaa.insertHeadNode(4);
aaa.insertHeadNode(6);
aaa.insertHeadNode(8);
aaa.insertHeadNode(45);
aaa.insertHeadNode(876);
// aaa.deleteHeadNode();
aaa.displayLink(aaa.first);
Node node = aaa.findNode(aaa.first, 8);
System.out.println(node.data + " next = " + node.next.data);
}}