[3298] in java-interest

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

Re: arrays of instances of objects

daemon@ATHENA.MIT.EDU (Laura Lemay, Killer of Trees)
Mon Nov 6 20:12:53 1995

Date: Mon, 6 Nov 1995 12:57:50 -0800
To: nrc2 <nrc2@aber.ac.uk>, java-interest@java.sun.com
From: lemayp@lne.com (Laura Lemay, Killer of Trees)

>I have a class called TreeNode that is a node of a Binary Tree and I
>want to declare an array of instances of this.  I've tried
>
>TreeNode Tree[] = new TreeNode[16];
>
>but this seems to declare an array of null pointers.

Yup.  That's what its supposed to do.  You then have to put TreeNode
objects into the array yourself:

Tree[1] = new TreeNode();
Tree[2] = new TreeNode();

etc.


Laura



-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

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