Implementing Linked List
Document Top addFirst() addLast() removeFirst() display() main() Output LINKED LIST IMPLEMENTATION class SinglyLinkedList1 { // Node class private static class Node { String data; Node next; Node(String data) { this.data = data; this.next = null; } } Singly Linked List variables private Node head; // points to the first node private Node tail; // points to the last node private int size; // tracks number of nodes Constructor public SinglyLinkedList1() { head = null; tail = null; size = 0; } To insert an element at the head (beginning) of the list: // Create a new node containing the new element. // Set its next reference to the current head node. // Reassign the head to point to this new node. // Increase the list size by one. // ...