[1554] in java-interest

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

Re: dynamic lists

daemon@ATHENA.MIT.EDU (ser@jersey)
Thu Sep 7 17:43:04 1995

From: ser@jersey
To: java-interest@java.sun.com
Date: Thu, 07 Sep 1995 10:35:26 -0700

weilerj@std.teradyne.com (Jason Weiler) said:
> Just cuz Java can't do pointers, doesn't mean you can't do linked  
> lists the old fashioned way. (Now if I'm wrong here, someone please 
> snap me back in line. :-) 

This is true.  Java does have with pointers, it just doesn't call them pointers, and what you can do with them is limited.  This always confuses me; for example:

    MyClass blah[] = new MyClass[10];

It is not immediately obvious to me that blah[] is an array of pointers, not an array of MyClass.  This distinction is important, as one gives you an array of uninitialized pointers, whereas the other gives you an array of instances of something.

The crux of matter is,

   int x;

refers to an instance of x, whereas

   MyClass x;

is a pointer to a non-existant instance of MyClass which I still have to fill with

   x = new MyClass();

or some similar pointer manipulation.  Personally, I find inconsistancies like this annoying, but acceptable.  After all, learning the intricacies of pointers was much more difficult than remembering that Some Things Are Always Auto-Instantiated by Java, and Some Things Aren't.  As long as you observe the casting rules of Java, you can use class instance references like pointers in any other language.

--- SER

-
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