ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 25 May 2017 My Price 8.00

temp.setNext

Can someone explain why 
temp.setNext(current.getNext()); has been used I am not understanding
public void add(Object data, int index)
        // post: inserts the specified element at the specified position in this list.
        {
                Node temp = new Node(data);
                Node current = head;
                // crawl to the requested index or the last element in the list,
                // whichever comes first
                for(int i = 1; i < index && current.getNext() != null; i++)
                {
                        current = current.getNext();
                }
                // set the new node's next-node reference to this node's next-node reference
                temp.setNext(current.getNext());
                // now set this node's next-node reference to the new node
                current.setNext(temp);
                listCount++;// increment the number of elements variable
        }

 

Answers

(11)
Status NEW Posted 25 May 2017 08:05 AM My Price 8.00

-----------

Not Rated(0)