previous | start | next

Add to Last Revised

The revised Add to Last code is similar, but it is now much more efficient than the initial version of Add to Last (The number of operations is fixed and doesn't depend on the length of the list):

Node tmp = new Node(20);
if (last == null) {
   start = last = tmp;
} else {
  last.next = tmp;
  last = tmp;
}      
   


previous | start | next