Issue With Collision Detection

So, for some reason when I try to add more solid objects into the scene I am only able to to collide with one of those objects and not the other ones.

Code for handling collision:

public void update() {
        for (int i = 0; i < objects.size(); i++)
            for (int j = i + 1; j < objects.size(); j++) {

                ArrayList<AABB> boxes = new ArrayList<AABB>();

               GameObject c0 = objects.get(i);
                GameObject c1 = objects.get(j);

                boxes.add(c1.getBoundingBox());

                objects.clear();



                for (int k = 0; k < boxes.size(); k++) {
                    AABB box = null;
                    if (box == null) box = boxes.get(k);
                    if (boxes.get(k) != null) {
                        Vector2F length1 = box.getCenter().sub(c1.getPosition().x, c1.getPosition().y, new Vector2F());
                        Vector2F length2 = boxes.get(k).getCenter().sub(c0.getPosition().x, c0.getPosition().y, new Vector2F());
                        if (length1.lengthSquared() > length2.lengthSquared()) box = boxes.get(k);
                    }

                    if (box != null) {
                        Collision data = c0.getBoundingBox().getCollision(box);
                        if (data.isIntersecting) {
                            c0.getBoundingBox().correctPosition(box, data);
                            c0.setPosition(c0.getBoundingBox().getCenter());
                        }
                    }
                }
            }
    }