Node temp = new Node(6,head,head.getNext()); Node temp1 = new Node(2,tail.getPrev(),tail); head.setNext(temp); temp.getNext().setPrev(temp); tail.setPrev(temp1); temp1.getPrev().setNext(temp1);