The Artima Developer Community
Sponsored Link

Java Answers Forum
java problem

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
julie

Posts: 1
Nickname: julie
Registered: Aug, 2003

java problem Posted: Aug 6, 2003 11:56 AM
Reply to this message Reply
Advertisement
I am creating a constructor in my EmailChromosome class which creates an individual chromosome in the form of a List (List chromo = new Vector();).
A single chromosome has 6 pattern objects in it. These pattern objects are names that are randomnly chosen from a names Hash Table. It is this names hashtable which is always null. I fill up my names hashtable by reading in a names file in my user inteface class using FileInput. The names and their corresponding scores are String Tokenized in my user interface class and then inserted into the hashtable and scores array respectively (by using a method call to EmailChromosome). However when I access my hashtable from within the EmailChromosome class it is always null. When the hashtable is accessed from the User Interface class it is always okay. My code structure is as follows:

User Interface Class
1. contains FileInput and StringTokenizer to read and tokenize the names file
2. contains a method call to EmailChromosome class for the method which puts the names and their scores into the appropriate hashtable and array.

EmailChromosome Class
1. public variables are the names hashtable and the scores array eg.
public Hashtable names = new Hashtable();
2. contains a method which creates the hashtable by putting the names in it and the scores into an array.

I firstly thought that the hashtable and the array should be initialised in another constructor in EmailChromosome, ( not in the same constructor which creates an individual chromosome) This constuctor is then used to call the appropriate method in the UserInterface but my hashtable in the EmailChromosome Class is still null.

Please can you give me an idea of how to solve this null pointer problem.

Topic: JScrollPane  problem Previous Topic   Next Topic Topic: java problems

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use