I need to create a variable-sized two-dimensional coordinate system. What I’ve been able to come up with so far is:
Vector<Coordinate> board = new Vector();
for ( int count = 0; count < num_rows; count++ ) {
board.add(new Vector(num_cols));
}
How do I access the elements within this multi-dimensional vector? I have tried doing board[row][col] but this didn’t seem to work.
I’m familiar with using Vectors in C++, but can’t seem to figure out how to do this in Java.
I don’t get how you are adding a Vector into a Vector of Coordinates.
You might try something like List<List<Coordinate>> board. Then use board.get(1).get(2) to get a position.
What you really might try is the Guava Table.
http://docs.guava-libraries.googlecode.com/git-history/release09/javadoc/index.html
Then it would be: