Pascal's Triangle Java (performance) I need to get some information about the Pascal Triangle.

What is a pascal triangle ?


  It is a triangle of integers with 1 at the top and at the sides. Any number inside is equal to the sum of the two numbers above his. For
  example, here are the first 5 lines of the triangle:




So I need to figure out the number of numbers
pairs that exist in the first thousand lines of the triangle.

I would like to know how I can improve the performance of my code or rewrite some part that is poorly structured

import java.sql.Date;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Vector;

public class PascalTriangle {

    private static int [][] matrix;
    private static int i, j, n;

    public static void main(String[] args) 
    { 

        long start_time = System.currentTimeMillis();  

        n = 0; // Number of even numbers;

        matrix = new int[1000][1000]; 

        for (i = 0; i &lt; 1000; i++) {        
            for (j = 0; j &lt; 1000; j++) {
                matrix[i][j] = 0;
            }
        }

        matrix[0][0] = 1;
        matrix[1][0] = 1;
        matrix[1][1] = 1;

        for (i = 2; i &lt; 1000; i++) {        
            matrix[i][0] = 1;
            matrix[i][i] = 1;
            for (j = 1; j &lt; i; j++) {
                matrix[i][j] = matrix[i-1][j-1]+matrix[i-1][j];
                if ( matrix[i][j] % 2 == 0 ) {
                    n++;
                }
            }
        }

        System.out.println( "Amount of even numbers = " + n );

        long end_time  = System.currentTimeMillis();   
        System.out.println(new SimpleDateFormat("ss.SSS").format(new Date(end_time - start_time)));  

    }
}


Expected result:

Amount of even numbers = 448363


Currently taking a time of 00.011 seconds
One array solution
The following algorithm is an improvement on the two array system stated bellow it.  Basically, we only need the context of the old previous value (as well as the next value, which goes unmodified), so we copy this value.  From there we can set the new end to 1 then start over.  This cuts down on the memory overhead.  I think you'll see minimal computational improvements as yours was already pretty efficient, but this one takes less memory.  I suspect there will be a performance increase where you are dealing with pretty large arrays.
import java.util.Arrays;

class Pascal{

     public static void main(String []args) {
        int toNthLine = 1000;
        int[] row = new int[toNthLine+1];
        int counter = 0;
        int previous;
        row[0] = 1;
        for (int i = 0; i &lt; toNthLine; i++) {
            previous = 1;
            for (int j = 0; row[j+1] != 0; j++) {
                int temp = row[j+1];
                row[j+1] = previous + row[j+1];
                previous = temp;
                if (row[j+1] % 2 == 0)counter++;
            }
            row[i] = 1;
        }
        System.out.println(counter);
     }
}