/** * This class implements a PDA singly linked list of characters in Java. */ public class PDATransitionLinkedList { public Node head; public Node tail; /** * Constructs a new singly linked list object. */ public PDATransitionLinkedList() { head = null; tail = null; } /** * Adds a node containing the character c to the end of the * linked list. * @param l The string to be added to the list. * @param s The string to be added to the list. * @param p The string to be added to the list. */ public void addNode(String l, String s, String p) { Node new_node = new Node(l, s, p); // If the list is empty, set the head and tail correctly. if (head == null) { head = new_node; tail = new_node; return; } // Otherwise just add to the tail. tail.setNext(new_node); tail = new_node; } }