i am running into problem here. I have a arraylist called rect which store all bounds for ground. i am looping though it and checking for collision between player and arraylist bounds.

tile map 2d array:

1 = player
2 = ground
0 = background
 
1,0,0,0
2,2,0,2
I want to print "FLAG 1" if its collisied but if its not than print "FLAG 2". I am not 100% sure but i think the problem is the loop.

if arraylist size is 10 than, if player is standing on ground than it will print "FLAG 1" but than it will print 9 times "FLAG 2"


public void collision(Player p){
this.getBounds();for(int i = 0; i < rect.size(); i++){
    if(p.getBounds().intersects(this.rect.get(i)))
          System.out.println("FLAG 1");
    else
                 System.out.println("FLAG 2");
}
}

not sure if i made my question clear. I want to only print "Flag 1" if its touch the ground. and when its not touching than i only want to print "Flag 2"