package DateStructuresHomework;
import homework.F;
public class SingleLinkedList {
private Node head=new Node("");
public void insert(Node Node)
{
Node temp=head;
while (true)
{
if (temp.next==null)
break;
temp=temp.next;
}
temp.next=Node;
display();
}
public void delete(int no)
{
Node temp=head;
for (int i = 0; i next;
}
temp.next=temp.next.next;
display();
}
public void find(Object x)
{
Node temp=head;
int n=0;
while (temp.next==null)
{
if (temp.val==x)
{
break;
}
n++;
}
System.out.println(n);
}
public void display()
{
Node temp=head;
while (temp.next==null)
System.out.print(temp.val+" ");
}
}
class Node{
public Object val;
public Node next;
public Object getVal() {
return val;
}
public void setVal(Object val) {
this.val = val;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}
public Node(Object val) {
this.val = val;
}
}
class Test2
{
public static void main(String[] args) {
Node node1=new Node(1);
Node node2=new Node(2);
SingleLinkedList singleLinkedList=new SingleLinkedList();
singleLinkedList.insert(node1);
singleLinkedList.insert(node2);
singleLinkedList.display();
}
}
你输入的代码呢,你只调用了system.out,system.in在哪调用过?