[1524] in java-interest

home help back first fref pref prev next nref lref last post

Re: dynamic lists

daemon@ATHENA.MIT.EDU (Richard Wahongan)
Wed Sep 6 23:25:09 1995

Date: Thu, 7 Sep 1995 10:35:04 +1000 (EST)
From: Richard Wahongan <n1061925@dodo.fit.qut.edu.au>
To: Jason Weiler <weilerj@std.teradyne.com>
Cc: java-interest@java.Eng.Sun.COM
In-Reply-To: <9509061749.AA01234@fudd.std.teradyne.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;
>  
>         protected ll (int newval) {
>                 value = newval;
>                 next = null;
>                 }
>  
>         public ll () {
>                 value = 0;
>                 next = null;
>                 }
>         public void addlink(int newval) {
>                 if (head == null) {
>                         head = new ll(newval);
>                         }
>                 else {
>                         point = head;
>                         while (point.next != null)
>                                 point = point.next;
>                         point.next = new ll(newval);
>                         }
>                 }
>         public void show() {
>                 if (head==null) {
>                         System.out.println("Sorry, head is null");
>                         }
>                 else {
>                         point = head;
>                         while (point != null) {
>                                 System.out.println(point.value);
>                                 point = point.next;
>                                 }
>                 }
>         }
>  
>         public static void main (String args[]) {
>                 ll top = new ll();
>                 top.addlink(0);
>                 top.addlink(1);
>                 top.addlink(5);
>                 top.addlink(3);
>                 top.show();
>                 top.show();
>         }
> }
> 
> ********************* stop code ********************* 
> 
> Well, that should just about do it.  I know it's not commented, but
> as I said, it was a test program to begin with, and it's very simple.
> 
> If anyone needs help with it, please drop me a line.
> 
> -Jason W.
> <weilerj@std.teradyne.com>
> 
> -
> Note to Sun employees: this is an EXTERNAL mailing list!
> Info: send 'help' to java-interest-request@java.sun.com
> 
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post