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.