kristof
kristof

Reputation: 1

Java exceeding the 65535 bytes with Array of Points and Llines

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?

Upvotes: 0

Views: 221

Answers (2)

Christian Kuetbach
Christian Kuetbach

Reputation: 16060

you can use a static initialiser:

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);
       }
   }
}

If the points cannot be calculated, because they are values, store them in a file, as peter wrote.

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533660

Read in the points from a text file e.g.

x0 y0
x1 y1
... etc

Read in the lines as a series of point numbers

1 5 etc
0 3 6 9 etc

You can use BufferedReader and split() or careful use of Scanner.

Instead of defining all your Points in advance you could define your lines as a series of points. This would be far easier to maintain.

1,2 3,4 5,6 etc
2,1 4,5 0,7 etc

Upvotes: 2

Related Questions