Возникает ошибка NullPointerException

Писал код и столкнулся с такой ошибкой. Не знаю что можно сделать. Ошибка вот такая Exception in thread "main" java.lang.NullPointerException at task1123.Task1123.main(Task1123.java:34).

package task1123;

import java.util.Scanner;
import java.util.Locale;



public class Task1123 {

public class point {
public int x;
public int y;

public point(int x, int y) {
    this.x = x;
    this.y = y;
}
}



public static double dist(point a,point b)
{
    return Math.sqrt((a.x - b.x)*(a.x - b.x)+(a.y - b.y)*(a.y - b.y));

}
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    sc.useLocale(Locale.US);
    point a[] = new point[1000];
    int n, p = 0, q = 1, r = 0,s = 1;
    double c, mn, mx;
    n = sc.nextInt();
    for(int i = 0; i < n; i++)
    {
        a[i].x = sc.nextInt();
        a[i].y = sc.nextInt();
        
    }
    mn = dist(a[0],a[1]);
    mx = mn;
    for(int i = 0;i < n - 1; ++i)
    for(int j = i + 1; j < n; ++j)
    {
        c = dist(a[i],a[j]);
        if(c < mn)
        {
            mn = c;
            p = i;
            q = j;
        }
        else if(c > mx)
        {
            mx = c;
            r = i;
            s = j;
        }
    }
}

}


Ответы (1 шт):

Автор решения: Igor
n = sc.nextInt();
for(int i = 0; i < n; i++)
{
    a[i] = new point(sc.nextInt(), sc.nextInt());
}
→ Ссылка