Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Deep/Shallow copy

$
0
0
Hi all,

I built my own Linked List class in java.
each element in the list is of type Node (has next and prev)

However, when I'm trying to remove an element from the list I create a node and assign it to my head Node (the first element in the list)
This is what I'm doing in order to search for the specific element I want to remove.


               Node tmp = head.next;
		while(tmp != null && tmp.data != obj){
			tmp = tmp.next;
		}



My question is:

How come 'head' does not change every-time I change tmp.
It just doesn't make any sense to me.


Thanks a lot,

Tal

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>