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?
Java

Avatar of undefined
Last Comment
benjami

8/22/2022 - Mon
SOLUTION
shinobun

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
benjami

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61