Gravity and collision problem

Hello! I recently began a school project where we are going to make a game by only using Java/JavaFX. Since i am kinda new to java i’ve stumbled across some issues with my gravity and collision methods, mainly collision i think since it’s far from flawless.
The problem i am having is when i implement some gravity to make the sprite fall, i set the falling to false on collision and set it to true again when in the air. Since the collision is pushing the sprite back the sprite thinks it 's in the air again so it just bounces on the tile.

I have asked the TA at my school and he suggested adding some padding, but i ain’t sure how to do that either and i am sure it’s a more efficient way to do it.

Here’s my collision code and the falling is just changing the y value and update it on ticks.
The collision is prob the main issue, but i don’t how to fix it.


for (int i = 0; i < hero.getMaps().getTileList().size(); i++) {
            Tile tile = hero.getMaps().getTileList().get(i);
    if (collision(tile)) {
                iY -= vY;
                falling = false;
                canJump = true;

            }
            else {
                falling = true;
            }

            if (hero.isDown() && collision(tile)) {
                iY -= vY;

            }

           else if (hero.isRight() && collision(tile)) {
                iX -= vX;

            }
           else if (hero.isLeft() && collision(tile)) {
                iX += vX;

            }
            if (hero.isUp() && collision(tile)) {

                iY +=  vY;


            }
        }
}

        public boolean collision(Tile tile) {
        boolean collisionDetect = false;

                if (hero.getiNinja().getSpriteFrame()
                        .getBoundsInParent().intersects(tile.getBoundsInLocal())) {
                        return true;
                    }
            return false;
    }


I appreciate all help!