c# instantiating custom objects
<p>Hey so far I have and I'm getting a null pointer error in my for loop
anybody know why?
thanks</p>

<p>here is the error message</p>

<p>Object reference not set to an instance of an object.</p>

<pre><code>    board = new BoardSquare[15][];

    String boardHtml = "";

     for (int i = 0; i &lt; 15; i++) {
            for (int k = 0; k &lt; 15; k++) {
                //if (board[i][k] == null)
                    board[i][k] = new BoardSquare(i, k);
                boardHtml += board[i][k].getHtml();//null pointer error here
            }
        }

     /**
     * A BoardSquare is a square on the FiveInARow Board
     */
    public class BoardSquare {
        private Boolean avail; //is this square open to a piece
        private String color;//the color of the square when taken
        private int x, y; //the position of the square on the board

        /**
         * creates a basic boardSquare
         */
        public BoardSquare(int x, int y) {
            avail = true;
            this.x = x;
            this.y = y;
            color = "red";//now added (thanks)
        }

        /**
         * returns the html form of this square
         */
        public String getHtml(){
            String html = "";

            html = "&lt;div x='" + x + "' y='" + y + "' class='" + (avail ? "available" : color) + "'&gt;&lt;/div&gt;";

            return html;
        }

        /**
         * if true, sets color to red
         * if false, sets color to green
         */
        public void takeSquare(Boolean red){
            if(red)
                color = "red";
            else 
                color = "green";
        }
    }
</code></pre>
