二元运算符的坏操作数类型

时间:2014-03-14 02:32:15

标签: java

我正在编写一个程序(这是其中的一部分):

for (int a = 0; a<=firstsplit.length-1; a++)
  {
  //skipping over values that say how many pieces are on board
      for (int i = 3; i <= 12; i++)
      {
      //compatible with piece numbers up to 12(max)
        if (Integer.parseInt(firstsplit[0])==i) {
           while (a >= 1 && a <= firstsplit[i]) {
                      continue;
                      }
      }
      }
   }

这个错误正在发生:

Board.java:41: error: bad operand types for binary operator '<='
           while (a >= 1 && a <= firstsplit[i]) {
                              ^
first type:  int
second type: String
1 error

任何帮助解决这个问题将不胜感激。我不是一个高级程序员,你可能会说。

1 个答案:

答案 0 :(得分:3)

您在这里正确比较:

Integer.parseInt(firstsplit[0])==i

但不是在这里:

a <= firstsplit[i]

你知道你需要做什么吗?