[JAVA rookie] ask questions about variable naming conflicts. Two I, one inside the for loop and one outside the for loop.

first paragraph code:

public class HelloWorld {
    
    public static void main(String[] args) {
        
        int i = 0;      //i
        for(int i = 0 ; i < 10 ; iPP) {   // i
            System.out.println(i);
        }
        
    }
}

the first piece of code has two I, one outside for and one inside for. The system prompts for naming conflicts

second paragraph code:

public class HelloWorld {
    
    public static void main(String[] args) {
        
        for(int i = 0; i < 10 ; iPP) {
            System.out.println(i);
        }
        
        for(int i = 0; i < 10 ; iPP) {
            System.out.println(i);
        }
        
    }
}
The second piece of code

has two juxtaposed for loops, each with a variable I, but the two do not collide with names.

I have two questions:
which of the two I is a local variable and which is a global variable in the first, first and second sections of code?
second, why the first code I name conflict, the second code I name conflict?

Jul.18,2022

this problem is the scope of variables

in the first code int I = 0; is in the entire main function, while the for loop is in the main function, so the system prompts for naming conflicts.

the scope of the two I in the second paragraph of code is in two for loops, so there is no conflict;

    public class HelloWorld {
    
        int hello=0; //
        
        
        
        public static void main(String[] args) {
        
            int j = 0;      //main
            
            for(int i = 0 ; i < 10 ; iPP) {   // for
            
                System.out.println(i);
                
            }
        }
    }
   
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdb61f-45804.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdb61f-45804.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?