[1529] in java-interest
Re: dynamic lists
daemon@ATHENA.MIT.EDU (Jason Weiler)
Thu Sep 7 00:07:53 1995
Date: Wed, 6 Sep 1995 17:47:10 -0700
From: weilerj@std.teradyne.com (Jason Weiler)
To: n1061925@dodo.fit.qut.edu.au
Cc: java-interest@java.Eng.Sun.COM
> Can anyone tell me why 'll head' and 'll point' in
> the declaration use static private, whereas 'll next' private only.
>
> And why ll(int newvalu) should be protected and not public ?
>
> Thanks !
>
> >
> > import java.lang.*;
> >
> > class ll {
> >
> > static private ll head=null;
> > static private ll point=null;
> > private int value;
> > private ll next=null;
'head' and 'point' are static because the 'head' of the
list and the end of the list (point) are common throughout all
nodes in the list. 'next' is an instance variable (non-static) because
each node needs an independent 'next' variable.
If next were made static, the list wouldn't hold together, because you'd
be changing the next reference for every node each and every time you add
a new node.
Does this clear things up, or did I miss your question entirely?
-Jason
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com