Compiler Error J0089

The case 'identifier' has already been defined in switch statement

The compiler identified two or more case statements with the same identifier or value occurring within the same switch statement.

The following example illustrates this error:

public class Simple {
   
   public int method1(int arg1) {
   
      switch (arg1) {
         case 1:
            return (int) 1;
         case 2:
            return (int) 2;
         case 2: // error: duplicate of above
            return (int) 3;
         default:
            return (int) 0;
      }
   }
}