Compiler Error J0151

Variable 'identifier' is already defined in this method

The compiler detected two variables with the same name that are defined twice within the same scope of a method. Ensure that a variable has not been defined twice in the same scope or that a variable has not been defined the same name as an argument passed to the method and compile again.

The following example illustrates this error:

public class Simple {
   
   public void method1() {
   
      int i = 1;
      int j = i;
      //more code here
      int i = 0;
      // error: 'i' defined twice within
      // the same scope
   
   }
}