A
Andrew Farrington
Can anyone shed some light on a small problecm I am having. If you want a
load of integer vaiables you can just use an array like int[] myMarks =
new int[10];
This means you don't have to declare 1o seperate variables.
my problem is I want to use lots of vectors but i don't want to define
each one implicitly. I would like an array of vectors or a vector of
vectors.
Vector myVector = new Vector(); normal declaration
Vector[] myVector = new Vector[8]; this is accepted but when i reference
in my code later with
for (int i=0; i<8; i++)
{
myVector.add("index: " + i);
}
I keep getting null pointer exceptions.
I am trying to implement a tree structure, NOT binary. I would like a
root, then 8 children and then on each child, another 8 children. Vectors
is the way I thought I could do it but I am struggling. Anyone help? or
can you recommend a better solution (not JTree as I don't want a graphical
representation).
cheers
andy
load of integer vaiables you can just use an array like int[] myMarks =
new int[10];
This means you don't have to declare 1o seperate variables.
my problem is I want to use lots of vectors but i don't want to define
each one implicitly. I would like an array of vectors or a vector of
vectors.
Vector myVector = new Vector(); normal declaration
Vector[] myVector = new Vector[8]; this is accepted but when i reference
in my code later with
for (int i=0; i<8; i++)
{
myVector.add("index: " + i);
}
I keep getting null pointer exceptions.
I am trying to implement a tree structure, NOT binary. I would like a
root, then 8 children and then on each child, another 8 children. Vectors
is the way I thought I could do it but I am struggling. Anyone help? or
can you recommend a better solution (not JTree as I don't want a graphical
representation).
cheers
andy