File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

an Array of Vectors Not working

John Lister

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

Teller tellersToday[] = new Teller[numberOfTellers];

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

I get after executing:
Exception in thread "main" java.lang.NullPointerException

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

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"

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:
subject: an Array of Vectors Not working
It's not a secret anymore!