public class example
{
static class point
{
int x;
int y;
}
static void main(String args[])
{
point p = new point();
point[] p1 = new point[5];
point[][] p2 = new point[5][5];
p.x = 5; //No problem
p[0].x = 5; //When I run the program, it gives error:java.lang.NullPointerException
p[0][0].x = 5; //When I run the program, it gives error:java.lang.NullPointerException
}
如何初始化 p[].x 和 p[][].x?