Hello,

I'm a student working on some homework and I can't get past or understand this small error. I'm only part way through so please ignore any other mistakes that you see but I'm having issues. I know which line of code is causing them but I don't understand why.

Exception in thread "main" java.lang.NullPointerException
at bonusProgram1.bonusProgram.readGraph(bonusProgram.java:87)
at bonusProgram1.bonusProgram.main(bonusProgram.java:21)

adjacencyMatrix[k].add(j); is causing the error. Any insight you can offer would be greatly appreciated.
Code:
package bonusProgram1;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.File;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;


public class bonusProgram {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		readGraph();
		//printGraph();
		//shortestPath();
		
			
	
	}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	private static void shortestPath() {
		// TODO Auto-generated method stub
		
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
	private static void printGraph() {
		// TODO Auto-generated method stub
		
	}

////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	@SuppressWarnings("unchecked")
	private static void readGraph() {
		// TODO Auto-generated method stub
		FileReader file = null;
		try {
			file = new FileReader("graph.txt");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Scanner scanner = new Scanner(file);
		ArrayList<Integer> listBegin =  new ArrayList<Integer>();
		ArrayList[] adjacencyMatrix;
		adjacencyMatrix = new ArrayList[10];
		for(int i =0;i < 9 ; i++){
			adjacencyMatrix [i] = new ArrayList<Integer>(); 
    	}
		int scan = 0;
		
		System.out.println("AM!!   " + adjacencyMatrix);
		while (scanner.hasNextLine()) {
			int line = scanner.nextInt();
			listBegin.add(line);
			scan += 1;
			}
		
		for (int i1 = 0; i1 < listBegin.size(); i1++){
			System.out.println("Reading line: " + listBegin.get(i1));
			}
		System.out.println("AM!!   " + adjacencyMatrix);
		
		
		for (int i2 = 0; i2 < listBegin.size(); i2 += 2){
			int j = (int)listBegin.get(i2);
			int h = i2 +1;
			int k = (int)listBegin.get(h);
			adjacencyMatrix[j].add(k);
			adjacencyMatrix[k].add(j);
			}
		
		
		for (int i = 0; i < adjacencyMatrix.length; i++){
			System.out.println("AM!! "+ i + adjacencyMatrix[i]);
			}
		
	}
}

/**********************************************
 * The sample input
 * 0 9
 * 1 2
 * 1 3
 * 2 4
 * 2 5
 * 3 6
 * 4 5
 * 4 7
 * 4 8
 * 5 6
 * 5 9
 * 8 9
***************************************************/