Mitsaki
Mitsaki

Reputation: 11

Java: float[][] points

I am using an open source program but I don't understand how I should write this class.

Room

public Room(float[][] points)
Creates a room from its name and the given coordinates.

I guessed it was something like

Room Parallelogram_Room = new Room{{0f,0f},{0f,400f},{625f,400f},{625f,400f},{625f,0f},{0f,0f}};

but it gives an error, or

Room Parallelogram_Room = new Room([0f][0f]);

but still gives an error.

Please, I am stuck!

Upvotes: 1

Views: 102

Answers (2)

Petar Minchev
Petar Minchev

Reputation: 47403

Use Room room = new Room(new float[][] { {3, 4}, {4, 5}, {4, 6} });

Upvotes: 4

Jeremy
Jeremy

Reputation: 22435

You're messing up the syntax. Wrap the array with parenthesis.

To make it more clear, create the array and then pass it into the constructor.

float[][] points = {{0f,0f},{0f,400f},{625f,400f},{625f,400f},{625f,0f},{0f,0f}};
Room Parallelogram_Room = new Room(points);

Upvotes: 4

Related Questions