added constructor

This commit is contained in:
Doru Kesriyeli 2018-10-07 17:28:50 -07:00 committed by GitHub
parent ae2029424b
commit 3562e83985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,12 +20,24 @@ class DoublyLinkedList{
private Link tail; private Link tail;
/** /**
* Constructor * Default Constructor
*/ */
public DoublyLinkedList(){ public DoublyLinkedList(){
head = null; head = null;
tail = 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 * Insert an element at the head