File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes problem with Static Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "problem with Static Vector " Watch "problem with Static Vector " New topic
Author

problem with Static Vector

Pratik Khetia
Ranch Hand

Joined: Jun 29, 2001
Posts: 50
I am designing a chat server and to keep track of the user that are logged on. I am using a class which has static method and a static Vector. But when I pass the argument from other program this static Vector gives an error...
"java.lang.NullPointer"
or if I initialise the vector then I lose the traack of the users as everytime it stores in a new instance of the Vector.
So if anyone has any idea...I would look forward to get some help
thanks
Pratik Khetia
Aleksey Matiychenko
Ranch Hand

Joined: Apr 03, 2001
Posts: 178
Well, you have to initialize the vector once. So how about putting something like this before accessing a vector
if (static_vector == null)
static_vector = new Vector();
... continue using vector

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with Static Vector
 
Similar Threads
Varaible row count in JTable
Vectors
protected variable of Vector
can someone help me out
garbage collection