0

So I have an array of Points

Point[] point ={new Point (x,y), ....}

And an array of Lines from those points

Line[] line = {new Line(point[1],point[5]),....}

If I store this in a class i exceed the 65535 bytes.

I thought of getting it from external files as splitting them up in other classes is no option. But the lines have to get their points from the point array.

So if anyone has an idea on how to do this?

4

2 回答 2

2

从文本文件中读取点,例如

x0 y0
x1 y1
... etc

将行读为一系列点号

1 5 etc
0 3 6 9 etc

您可以使用 BufferedReader 和 split() 或仔细使用 Scanner。

您可以将线定义为一系列点,而不是提前定义所有点。这将更容易维护。

1,2 3,4 5,6 etc
2,1 4,5 0,7 etc
于 2013-01-23T22:08:58.033 回答
0

您可以使用静态初始化程序:

static {
   Point[] points;
   int i =0;
   for(int x=0;x<something;x++){
       for(int y=0;y<something;y++){
           point[i] = new Point(x,y);
       }
   }
}

如果这些点无法计算,因为它们是值,请将它们存储在一个文件中,如 peter 所写。

于 2013-01-23T22:23:00.577 回答