class SLLDelDemo {
static class Node {
String name;
Node next;
}
public static void main (String [] args) {
Node top = new Node ();
top.name = "Jordan";
top.next = null;
Node temp = new Node ();
temp.name = "Eduardo";
temp.next = top;
top = temp;
temp = new Node ();
temp.name = "";
temp.next = top;
top = temp;
temp = new Node ();
temp.name = "Jorge";
temp.next = top;
top = temp;
dump (" ", top);
top = top.next;
dump (" ", top);
temp = new Node ();
temp.name = "Jorge";
temp.next = top;
top = temp;
temp = top;
while (temp.name.equals ("Camilo") == false)
temp = temp.next;
temp.next = temp.next.next;
dump (" ", top);
}
static void dump (String msg, Node topNode) {
System.out.print (msg + " ");
while (topNode != null) {
System.out.print (topNode.name + " ");
topNode = topNode.next;
}
System.out.println ();
}
miércoles, 11 de marzo de 2009
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario