如果变量名称已更改,则重复本地变量结束+错误

时间:2013-12-29 02:15:41

标签: java variables duplicates

变量MoveCheckend出错。这是一个反热插件:

if (inc >= moves.size())
      {
        MoveCheck tmp235_232 = Instance; tmp235_232.getClass(); jumps.add(new Jump(start, (MoveLog)moves.get(inc - 1), (MoveLog)moves.get(inc - 1)));
        break;
      }

      MoveLog apex = (MoveLog)moves.get(inc - 1);
      boolean isFloating = false;
      boolean isOnFire = false;
      int floatCount = 0;

      while ((inc < moves.size()) && (((MoveLog)moves.get(inc)).isAir))
      {
        if (((MoveLog)moves.get(inc - 1)).location.getY() <= ((MoveLog)moves.get(inc)).location.getY())
        {
          floatCount++;

          if (floatCount > 3)
            isFloating = true;
        }
        else
        {
          floatCount = 0;
        }

        if (((MoveLog)moves.get(inc)).isOnFire) {
          isOnFire = true;
        }
        inc++;
      }
      MoveLog end;
      MoveLog end; //error duplicate variable -if rename end1 whith other end = error

      if (inc >= moves.size())
        end = (MoveLog)moves.get(moves.size() - 1);
      else
        end = (MoveLog)moves.get(inc);
      MoveCheck tmp433_430 = Instance; tmp433_430.getClass(); Jump jump = new Jump(start, apex, end);
      jump.isFloating = isFloating;
      jump.isOnFire = isOnFire;
      jumps.add(jump);
    }

1 个答案:

答案 0 :(得分:0)

首先,你应该在你的moves集合中使用适当的泛型(我假设是一个列表) -

List<MoveLog> moves; // <-- something like that.

其次,您可以使用三元组(我保留了演员表,但如果您执行第1步,则不需要它们) -

MoveLog end = (inc >= moves.size()) ? (MoveLog) moves.get(moves.size() - 1) : 
                                      (MoveLog) moves.get(inc);

您不能同时在范围内有两个名为end的变量。