Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An array of Vectors ? not possible?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi In my application I need to build an Array of vectors
ex: Vector[] list = new Vector[100];
then I want to add elements in the vectors that I chose in my list
ex: list[3].addElement("hello");

But I get an NullPointer Exception at RunTime!!!

What the hell? It works fine for an array of Strings
ex: String[] strList = new String[100];
//and do
strList[3] = "hello";
And there are both Objects!

But I need a Vector (number of elements varies importantly..)
Does anyone know how to overcome this? Thanks!!
 
OK nevermind,, I found out. its kinda weird yet comprehensible.. you have to instanciate each vector of the array before you use it..
in my previous example I would have to do:
list[3] = new Vector(); // then I can do:
list[3].addElement("hello");
... duh! for some but not for me,,, :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top