I started learning Java and have small problem. I have classes Point and abc:
static class Point
{
int x;
int y;
Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
static class abc
{
abc()
{
Scanner s = new Scanner(System.in);
Point[] p = new Point[2];
for (int i = 0; i < 2; ++i) {
p[i].x = s.nextInt();
p[i].y = s.nextInt();
}
}
}
But initialization in class abc doesn't work. When I try to write first number it gives:
Exception in thread "main" java.lang.NullPointerException
at main$abc.<init>(main.java:91)
at main.main(main.java:99)
What should I do to make it work?