It seems that last for loop doesn't see int max, even if it's right in the beginning of the ArrayList. Can someone please explain why does this happen and where's the mistake in my thinking? Also, when I tried the last for loop without break it printed out all of the correct words (both int min & int max), but the int max was still last even though I put it in the beginning of the list to see what's going on.