Is there any doubly linked list implementation in Java?

Yes, LinkedList is a doubly linked list, as the Javadoc mentions : Doubly-linked list implementation of the List and Deque interfaces. Implements all optional list operations, and permits all elements (including null). All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list … Read more

Printing out a linked list using toString

public static void main(String[] args) { LinkedList list = new LinkedList(); list.insertFront(1); list.insertFront(2); list.insertFront(3); System.out.println(list.toString()); } String toString() { String result = “”; LinkedListNode current = head; while(current.getNext() != null){ result += current.getData(); if(current.getNext() != null){ result += “, “; } current = current.getNext(); } return “List: ” + result; }

Iterator for a linkedlist

1) SortedLinkedList extends BasicLinkedList but both have private Node head; private Node tail this is wrong. If you want to inherit those field in the sub class, you should mark the variables as protected in the super class and remove them from the subclass. 2) Same goes for private class Node. You are declaring the Node class in both the SortedLinkedList and BasicLinkedList. … Read more