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