Write a function that deletes and returns the last link of a Linked List?
public Link deleteLast(){ /* If the list is empty, function returns null */ if(first == null) return null; else{ Link current = first; Link previous = null; while(current.next! = null){ previous = current; current = current.next; } /* If the list has one element, update 'first' */ if(previous == null) first = null; else previous.next = null; } return current; }