/other methods go here the constructor for linklist sets first to null this isn' really necessary because as we notedreferences are set to null automatically when they're created howeverthe explicit constructor makes it clear that this is how first begins when first has the value nullwe know there are no items on the list if there were any itemsfirst would contain reference to the first one the isempty(method uses this fact to determine whether the list is empty the insertfirst(method the insertfirst(method of linklist inserts new link at the beginning of the list this is the easiest place to insert linkbecause first already points to the first link to insert the new linkwe need only set the next field in the newly created link to point to the old first linkand then change first so it points to the newly created link this is shown in figure in insertfirst(we begin by creating the new link using the data passed as arguments then we change the link references as we just noted /insert at start of list public void insertfirst(int iddouble dd/make new link link newlink new link(iddd)newlink next first/newlink --old first first newlink/first --newlink the arrows --in the comments in the last two statements mean that link (or the first fieldconnects to the next (downstreamlink (in doubly linked lists we'll see upstream connections as wellsymbolized by <-arrows compare these two statements with figure make sure you understand how the statements cause the links to be changedas shown in the figure this kind of reference-manipulation is the heart of linked list algorithms the deletefirst(method the deletefirst(method is the reverse of insertfirst(it disconnects the first link by rerouting first to point to the second link this second link is found by looking at the next field in the first link public link deletefirst(link temp firstfirst first nextreturn temp/delete first item /(assumes list not empty/save reference to link /delete itfirst-->old next /return deleted link