diff --git a/DataStructures/Lists/DoublyLinkedList.java b/DataStructures/Lists/DoublyLinkedList.java index 1d15e495..d236fe68 100644 --- a/DataStructures/Lists/DoublyLinkedList.java +++ b/DataStructures/Lists/DoublyLinkedList.java @@ -20,12 +20,24 @@ class DoublyLinkedList{ private Link tail; /** - * Constructor + * Default Constructor */ public DoublyLinkedList(){ head = null; tail = null; } + + /** + * Constructs a list containing the elements of the array + * @param array the array whose elements are to be placed into this list + * @throws NullPointerException if the specified collection is null + */ + public DoublyLinkedList(int[] array){ + if (array == null) throw new NullPointerException(); + for (int i:array) { + insertTail(i); + } + } /** * Insert an element at the head