Why does the count variable has to be defined outside the curly brackets of the for loop? (Refer to the codes) : Please read till the end, so that you will understand the problem completely. 
    
    As you can see in the two below codes, I get different results when I use the count variable outside the for loop curly brackets. Can someone please tell me why? 
    
As you can see the first result only prints three i values.
So my question is why the count variable can not be defined in the curly brackets of the for loop as I have done in the first code. Please help. Thank you.

public class Main {

    public static void main(String[] args) {
        int count = 0;
    for (int i=0; i<5; i++) {

        System.out.println(i);
        count++;
        if (count == 3) {
            break;
        }
    }
    }
}





public class Main {

    public static void main(String[] args) {
        
    for (int i=0; i<5; i++) {
        int count = 0;
        System.out.println(i);
        count++;
        if (count == 3) {
            break;
        }
    }
    }
}