I am used to coding in PHP but I am not really proficient with Java and this has been a problem for some time now. I expect it to be a fairly easy solution, however I cannot
This is two separate questions: how to simulate negative array indicies so you can have an "infinite" map, and how to store tiles efficiently.
On the first question, one hack would be to maintain four separate matricies (matrixes?), one for each quadrant. Then all the indexes can be positive.
On the second question, you need a sparse map. One not-very-efficient way is to have a hashmap of hashmaps. In fact, that could solve the first problem as well:
HashMap x = new HashMap()
HashMap y = new HashMap()
// get the tile at coordinates 1,2
Tile myTile = x.get("1").get("2");
// this would work as well
myTile = x.get("-1").get("-2");
You could do your own Map implementation that took integers as keys and was much, much more efficient.