aspose file tools*
The moose likes Java in General and the fly likes an Array of Vectors Not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "an Array of Vectors Not working" Watch "an Array of Vectors Not working" New topic
Author

an Array of Vectors Not working

John Lister
Greenhorn

Joined: Oct 05, 2003
Posts: 3
My code is

Teller tellersToday[] = new Teller[numberOfTellers];

// Completly ineffeciant but it works.
Vector line[] = new Vector[numberOfTellers];


line[0].add((Teller)tellersToday[1]);
I get after executing:
Exception in thread "main" java.lang.NullPointerException
at myprojects.bank.EventItem.startEventSystem(Bank.java:205)
at myprojects.bank.EventItem.<init>(Bank.java:140)
at myprojects.bank.Bank.displayStartQuestions(Bank.java:114)
at myprojects.bank.Bank.main(Bank.java:28)

Can I not do this? Or what am I doing wrong?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by John Lister:
Teller tellersToday[] = new Teller[numberOfTellers];

This line is only instantiating an array *of references to Vector objects*. The references are initialized with null values. If you want them to point to actual Vector objects, you need to assign those to them.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
John Lister replied with this (moved from accidental new post):
Here is what Teller is:

So If I put something into the object like currentCusomer then it would work?


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: an Array of Vectors Not working