2d Array Help

I'm trying to make a 2d Array of Point2D, but it won't accept it. Here's what I got so far. All the variables (a, b, xlim, ylim) have been declared already...

Point2D[][] corners

Point2D[] tl =

{

new Point2D.Double(a-b, a-b),

new Point2D.Double(a+b, a-b),

new Point2D.Double(a+b, a+b),

new Point2D.Double(a-b, a+b)

};

Point2D[] tr =

{

new Point2D.Double((xlim-a)-b, a-b),

new Point2D.Double((xlim-a)+b, a-b),

new Point2D.Double((xlim-a)+b, a+b),

new Point2D.Double((xlim-a)-b, a+b)

};

Point2D[] bl =

{

new Point2D.Double(a-b, ylim-a-b),

new Point2D.Double(a+b, ylim-a-b),

new Point2D.Double(a+b, ylim-a+b),

new Point2D.Double(a-b, ylim-a+b)

};

Point2D[] br =

{

new Point2D.Double((xlim-a)-b, (ylim-a)-b),

new Point2D.Double((xlim-a)+b, (ylim-a)-b),

new Point2D.Double((xlim-a)+b, (ylim-a)+b),

new Point2D.Double((xlim-a)-b, (ylim-a)+b)

};

corners = { tr, tl, bl, br };

The last line's where the error is. It says "Array constants can only be used in initializers" How do I fix this? Thanks in advance

[1199 byte] By [Muchabia] at [2007-11-27 5:36:23]
# 1

the corners part I think is easy. Just declare

Point2D[][] corners = { tr, tl, bl, br };

on the last line. You can only use the short hand to set an array = to {..., ..., ...} when you initially declare it. Otherwise you have to loop through the indices.

I'm not sure what your other entries mean tho

Point2D[] tr =

{

new Point2D.Double((xlim-a)-b, a-b),

......

ps, please learn to use code tags. No one will want to read your code unless it is formated in a way that is easy to read.

petes1234a at 2007-7-12 15:06:58 > top of Java-index,Java Essentials,New To Java...
# 2
Sorry about not using tags, and thanks, it worked.
Muchabia at 2007-7-12 15:06:58 > top of Java-index,Java Essentials,New To Java...