I am a beginner in java programming. I am trying to develop a program but when I ran my program which is posted below and it came back with this error:
Exception in thread "main" java.lang.NullPointerException at dist.main(dist.java:13)
import java.lang.Math;
class Point { 
    int x;   int y;
}
public class dist {
    public static void main(String[] args) {    
        Point[] pt = new Point[3];
        pt[0].x = 40; pt[0].y = 40;
        pt[1].x = 40; pt[1].y = 30;
        pt[2].x = 26; pt[2].y = 30;
for(int i = 0 ;i < pt.length ; i ++){
         pt[i] = new Point();
}
        int ux = pt[0].x - pt[1].x;
        System.out.println("ux:" + ux);     
    }
} 
 
     
     
     
    