如何将数字与DOUBLE脚本数组中的第一个值的索引进行比较?

时间:2012-12-18 02:31:50

标签: java char arrays

例如,如果我有一个像这样的char数组:[a b d c]此数组中的'c'索引将为(0,1)。你如何将0与整数进行比较?

1 个答案:

答案 0 :(得分:0)

这是你想要的吗?

public class jtest
{
  public static void main(String args[])
  {
    new jtest();
  }

  public jtest()
  {
    char[][] myChars = {{'a', 'b'}, {'c', 'd'}};

    // myChars[x][y]
    for (int x = 0; x < myChars.length; x++)
    {
      for (int y = 0; y < myChars[0].length; y++)
      {
        if (x == 1) // compare the index value of X with some integer
          System.out.println(myChars[x][y]);
      }
    }
  }
}