java - Class for Doubly-Linked List -
i have code class handling doubly-linked list doesn't have empty head or tail node. have modified code obtained supposed doubly-linked list throwing following exception. how prevent exception occurring , changes required remove empty head or tail node? exception in thread "main" java.lang.nullpointerexception @ p4dll.removelast(p4dll.java:105) @ p4dll.main(p4dll.java:197) code: class listnode { object element; listnode next; listnode prev; public listnode( object anelement ) { element = anelement; next = null; prev = null; } public listnode( object anelement, listnode nextptr, listnode prevptr) { element = anelement; next = nextptr; prev = prevptr; } } // end class listnode public class p4dll { private listnode head; private listnode tail; private int size; public p4dll() { head = null; tail = null; size = 0; } pu...