I am making a 3D game with OpenGL (via LWJGL) and I have been using a 3 dimensional array to store every vertex from models. (for collision detection, and knowing what is where)

From the World class:
		this.length = 700;
		this.width = 700;
		this.height = 700;
		this.multiplier = 100;
		this.data = new GameObject[length][height][width];

But when I do this, I run out of heap space. This seems like an obviously bad way of doing things, but I don't know how else to do it.

I had 2 possible ideas:

1. There is another, better way of storing large amounts of data

2. I make a method like this

public List<GameObject> allObjectsInWorld = new ArrayList<GameObject>();
public GameObject getObjectAt(int x, int y, int z)
       for(int i = 0; i < allObjectsInWorld.size(); i++)
             GameObject cur = allObjectsInWorld.get(i);
             for(int j = 0; j < cur.model.vertices.length; j++)
                   if(cur.model.vertices.get(j) == new Vector3f(x, y, z))
                           return cur;
       return null;