added constructor
This commit is contained in:
parent
ae2029424b
commit
3562e83985
@ -20,13 +20,25 @@ 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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user