How to create a two dimensional array that supports negative indices java

409 views Asked by At

Is it possible to create a two dimensional array that supports negative and positive indices from points -10,-10 to 10,10? E.g. an array to simulate an x,y graph? E.g. point -10,4 should be in the index -10,4 in the array. I did try doing this but turns out Java does not allow negative indices..

I was thinking of creating some sort of mapping that maps those coordinates to an element in the index e.g. -10,-10 maps onto the [0][0] element but wanted to know if there was something easier than this.

0

There are 0 answers