我尝试了多次,无法获得程序中的索引

时间:2017-11-12 04:25:28

标签: java

我想让学生的索引返回 但它无法比较。我不知道这里有什么需要 会把一个人弄明白吗

public int search(String[][] student, String searchKey) {
    int search = 0;
    int column = student.length;
    int row = student[1].length;
    for (int i = 0; i < column; i++) {
        for (int j = 0; j < row; j++) {
            System.out.printf("%s", student[i][j]);
            if ((student[i][j]).equals(searchKey))
                search = i;

        }
    }
    return -1;
}

1 个答案:

答案 0 :(得分:0)

df4

  ID events.location.John.round.1 events.location.John.round.2 events.location.Mary.round.1 events.location.Mary.round.2
1  1                      A, B, C                      A, D, E                           NA                      A, B, E
2  2                      B, C, E                           NA                           NA                           NA
3  3                         A, C                         B, C                         B, C                         B, A
4  4                      D, E, B                      B, E, C                         E, A                      D, E, C
  events.location.John.round.1_Len events.location.John.round.2_Len events.location.Mary.round.1_Len events.location.Mary.round.2_Len
1                                3                                3                                0                                3
2                                3                                0                                0                                0
3                                2                                2                                2                                2
4                                3                                3                                2                                3
  events.location.John.round.1_A events.location.John.round.2_A events.location.Mary.round.1_A events.location.Mary.round.2_A
1                              1                              1                              0                              1
2                              0                              0                              0                              0
3                              1                              0                              0                              1
4                              0                              0                              1                              0
  events.location.John.round.1_B events.location.John.round.2_B events.location.Mary.round.1_B events.location.Mary.round.2_B
1                              1                              0                              0                              1
2                              1                              0                              0                              0
3                              0                              1                              1                              1
4                              1                              1                              0                              0
  events.location.John.round.1_C events.location.John.round.2_C events.location.Mary.round.1_C events.location.Mary.round.2_C
1                              1                              0                              0                              0
2                              1                              0                              0                              0
3                              1                              1                              1                              0
4                              0                              1                              0                              1
  events.location.John.round.1_D events.location.John.round.2_D events.location.Mary.round.1_D events.location.Mary.round.2_D
1                              0                              1                              0                              0
2                              0                              0                              0                              0
3                              0                              0                              0                              0
4                              1                              0                              0                              1
  events.location.John.round.1_E events.location.John.round.2_E events.location.Mary.round.1_E events.location.Mary.round.2_E
1                              0                              1                              0                              1
2                              1                              0                              0                              0
3                              0                              0                              0                              0
4                              1                              1                              1                              1

试试这个