/end main(/display again /end class firstlastapp for simplicityin this program we've reduced the number of data items in each link from two to one this makes it easier to display the link contents (remember that in serious program there would be many more data itemsor reference to another object containing many data items this program inserts three items at the front of the listinserts three more at the endand displays the resulting list it then deletes the first two items and displays the list again here' the outputlist (first-->last) list (first-->last) notice how repeated insertions at the front of the list reverse the order of the itemswhile repeated insertions at the end preserve the order the double-ended list class is called the firstlastlist as discussedit has two data itemsfirst and lastwhich point to the first item and the last item in the list if there is only one item in the listthen both first and last point to itand if there are no itemsthey are both null the class has new methodinsertlast()that inserts new item at the end of the list this involves modifying last next to point to the new linkand then changing last to point to the new linkas shown in figure figure insertion at the end of list the insertion and deletion routines are similar to those in single-ended list howeverboth insertion routines must watch out for the special case when the list is empty prior to the insertion that isif isempty(is truethen insertfirst(must set last to the new linkand insertlast(must set first to the new link if inserting at the beginning with insertfirst()first is set to point to the new linkalthough when inserting at the end with insertlast()last is set to point to the new link deleting from the start of the list is also special case if it' the last item on the listlast must be set to point to null in this case