Link to home
Start Free TrialLog in
Avatar of jpking72
jpking72

asked on

Hashtables

I have 4 tables to construct.  Can I make arrays of hashtables?  What is the best way to deal with this data?  Do I make one hashtable per table then store the keys and values as Arrays?  How do I do this?
SOLUTION
Avatar of shinobun
shinobun

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jpking72
jpking72

ASKER

OK I created the array of hashtables.  Now I get a null pointer exception as noted below.  

 Hashtable[] ht = new Hashtable[50];
    Hashtable[] ht2 = new Hashtable[50];
    Hashtable[] ht3 = new Hashtable[50];
    String a;
    String POS[] = {"<s>","VB","TO","NN","PPSS"};
    double num;
   
       
    try {
   
        FileReader fr = new FileReader(args[0]);
         BufferedReader br = new BufferedReader(fr);
               
    for (int i = 0; i < 6; i++)
    {
         a = br.readLine();
               
         StringTokenizer st = new StringTokenizer(a, " ");
        int j = 0;
         while(st.hasMoreTokens()) {
          num = Double.parseDouble(st.nextToken());
          ht[i].put(POS[j],new Double(num));  <---------------------- this line gives a null pointer exception
           j++;
    } // end of while
    }// end of for
     
    } // end of try
     catch(Exception e) {
            System.out.println("Exception: " + e);
       
    }
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial