I am writing a Java program in which I define a class
class Point { double x; double y; }
Then in the method, I define an array of points as follows:
Point[] line = new Point[6];
In the same method, I have a line
line[SampleSize - i + 1].x = i;
The first time you press this operator, the value of its array index is 1; but the program throws a null pointer exception at this point.
It would seem that this is the correct way to index the field of an object within an array of objects. What am I doing wrong?
Thanks in advance for any suggestions.
John doner
source share