I have a file with values like:
a,9,1
b,2,4
c,2,4
till *,2,0 and this is my code:
public static final String letterFileLoc = "filelocation";
public static Map<Character, Integer> letterValueMap;
public static Map<Character, Integer> letterCountMap;
public static void constructLetterMaps() throws FileNotFoundException{
File pointvals = new File(letterFileLoc);
Scanner pts = new Scanner(pointvals);
while (pts.hasNext()){
String [] parts = pts.next().split(",");
char alpha = (parts[0]).charAt(0);
int counts = Integer.parseInt(parts[1]);
int values = Integer.parseInt(parts[2]);
letterValueMap.put(alpha, values);
letterCountMap.put(alpha, counts);
}
and I keep getting a null pointer expception when I'm putting the values. I don't understand why. Could someone please explain?