You are on page 1of 1

package prelim;

public class MySinglyLinkedList {

public static Node<Character> createNode()

Node<Character> node = new Node<Character>();


node.data = null;
node.next=null;
return node;

public static void PrintList(Node<Character> head)

Node<Character> curr = head;


System.out.println();
while(curr!=null)

System.out.print(curr.data + "-->");
curr = curr.next;

System.out.print("null");

public static void main(String args[])

Node<Character> head = createNode();


head.Node('A');
Node<Character> node1 = createNode();
node1.Node('B');
head.setNext(node1);
Node<Character> node2 = createNode();
node2.Node('C');
node1.setNext(node2);
Node<Character> node3 = createNode();
node3.Node('D');
node2.setNext(node3);
PrintList(head);
}
}

This study source was downloaded by 100000851302356 from CourseHero.com on 08-30-2022 04:07:58 GMT -05:00

https://www.coursehero.com/file/106700425/MySinglyLinkedListjava/
Powered by TCPDF (www.tcpdf.org)

You might also like