J
justplain.kzn
Hi,
I am new to java programming and seem to have got myself into a bit of
confusion with assigning and using reference variables.
Below is a snippet of code I an using for a linkedlist.
public class LinkedList
{
private Node start;
public LinkedList()
{
start=null;
}
public Node find (int x)
{
if (start==null || start.data>0)
return null;
Node p = start; //*************** help
while (p.next != nul && !(p.next.data > x))
p=p.next;
return p;
}
....
....
}
Can some please point out and explain to me why when assigning
reference 'start' to p and then using p within the while loop, start is
NOT affected/changed?
thanks in advance...
I am new to java programming and seem to have got myself into a bit of
confusion with assigning and using reference variables.
Below is a snippet of code I an using for a linkedlist.
public class LinkedList
{
private Node start;
public LinkedList()
{
start=null;
}
public Node find (int x)
{
if (start==null || start.data>0)
return null;
Node p = start; //*************** help
while (p.next != nul && !(p.next.data > x))
p=p.next;
return p;
}
....
....
}
Can some please point out and explain to me why when assigning
reference 'start' to p and then using p within the while loop, start is
NOT affected/changed?
thanks in advance...