Java Reference
In-Depth Information
Display 15.20 Adding a Node between Two Nodes
1 . Existing list with the iterator positioned at “shoes”
"coat"
"orange juice"
"shoes"
null
head
previous
position
2. Create new Node with “socks” linked to “shoes”
temp = new Node (newData, position); // newData is "socks"
"coat"
"orange juice"
"shoes"
null
head
previous
position
temp
"socks"
Local variable of type Node
3. Make previous link to the Node temp
previous. link = temp;
"coat"
"orange juice"
"shoes"
null
head
previous
position
"socks"
temp
4. Picture redrawn for clarity, but structurally identical to picture 3
"coat"
"orange juice"
"socks"
"shoes"
null
head
previous
temp
position
Search WWH ::




Custom Search