Q:

null object in HashTable

When i try map.get(k) the index in my hashtable it returns null and was wondering if it was my csv to hashtable code.
public static void main(String[] args) throws ParseException, IOException {

    BufferedReader br = new BufferedReader(new FileReader("primes.csv"));
    String line =  null;
    Hashtable<String, String> map = new Hashtable<String, String>(100);

    while((line = br.readLine()) != null){
        String str[] = line.split(",");

        map.put(str[0], str[1]);
    }
    br.close();
    System.out.println(map);

    int k;

    k = Integer.parseInt(JOptionPane.showInputDialog(f,"Enter an integer k whee"
            + " 3 < k < 1229: "));

    while (k <= 3 || k >= 1229){
       k = Integer.parseInt(JOptionPane.showInputDialog(f,"Sorry try again: "));
    }

    JOptionPane.showMessageDialog(f, "The "+ k +"th prime number is " + map.get(k));

}   

Also my csv file contains

1, 1 (next line)
2, 2 (next line)
3, 3 (next line)
4, 5 (next line)
5, 7 and so on

A:

You use String keys in your map and you want to retrieve objects from it with  Integer keys :
String str[] = line.split(",");
...
map.put(str[0], str[1]);
...
int k;
...
map.get(k);

It is not possible. These are not equals in terms of equals().

So, use the same type as key in both cases.
For example to use String in both cases, change the get() invocation in this way :
map.get(String.valueOf(k));

Besides, Hashtable is a thread safe class (not efficient too).
You don't need to this feature in your code sample.
A HashMap is enough.

