无法从多维数组中获取要显示的信息

时间:2011-01-16 13:53:33

标签: java multidimensional-array

嘿,我为我的单人作品制作了一个多维数组,因为它不起作用,我复制了正确的单词,但没有复制,但是按照我上次的方式进行操作,如果有人能告诉我什么,没有任何作用我的部分代码是错的,请

import javax.swing.JOptionPane;

公共类CMS_Program {

public static void main(String args [])    {

  String Profiles[][] = new String[9][7];








  Profiles[0][0] = "Frank Barnes";
  Profiles[0][1] = "Male";
  Profiles[0][2] = "Reykjavik";
  Profiles[0][3] = "swim Time 15:49";
  Profiles[0][4] = "Cycle Time 20:30";
  Profiles[0][5] = "Running Time 45:50";
  Profiles[0][6] = "Over 18";

  Profiles[1][0] = "Amy Chadwick";
  Profiles[1][1] = "Female";
  Profiles[1][2] = "Reykjavik";
  Profiles[1][3] = "swim Time 14:30";
  Profiles[1][4] = "Cycle Time 19:59";
  Profiles[1][5] = "Running Time 36:30";
  Profiles[1][6] = "Under 18";

  Profiles[2][0] = "Rene Thatcher";
  Profiles[2][1] = "Female";
  Profiles[2][2] = "Reykjavik";
  Profiles[2][3] = "swim Time 12:21";
  Profiles[2][4] = "Cycle Time 22:30";
  Profiles[2][5] = "Running Time 45:50";
  Profiles[2][6] = "Under 18";

  Profiles[3][0] = "Archie McPhadden";
  Profiles[3][1] = "Male";
  Profiles[3][2] = "Reykjavik";
  Profiles[3][3] = "swim Time 13:30";
  Profiles[3][4] = "Cycle Time 21:20";
  Profiles[3][5] = "Running Time 38:57";
  Profiles[3][6] = "Under 18";

  Profiles[4][0] = "Ellen Palmer";
  Profiles[4][1] = "Female";
  Profiles[4][2] = "Reykjavik";
  Profiles[4][3] = "swim Time 16:58";
  Profiles[4][4] = "Cycle Time 24:45";
  Profiles[4][5] = "Running Time 41:19";
  Profiles[4][6] = "Over 18";

  Profiles[5][0] = "Gerald Field";
  Profiles[5][1] = "Male";
  Profiles[5][2] = "Reykjavik";
  Profiles[5][3] = "swim Time 21:50";
  Profiles[5][4] = "Cycle Time 25:50";
  Profiles[5][5] = "Running Time 43:20";
  Profiles[5][6] = "Under 18";

  Profiles[6][0] = "Fay Brier";
  Profiles[6][1] = "Female";
  Profiles[6][2] = "Reykjavik";
  Profiles[6][3] = "swim Time 14:20";
  Profiles[6][4] = "Cycle Time 22:53";
  Profiles[6][5] = "Running Time 47:23";
  Profiles[6][6] = "Over 18";

  Profiles[7][0] = "Richard Ranking";
  Profiles[7][1] = "Male";
  Profiles[7][2] = "Reykjavik";
  Profiles[7][3] = "swim Time 12:43";
  Profiles[7][4] = "Cycle Time 26:34";
  Profiles[7][5] = "Running Time 38:26";
  Profiles[7][6] = "Under 18";

  Profiles[8][0] = "Amy Chadwick";
  Profiles[8][1] = "Female";
  Profiles[8][2] = "Gibraltar";
  Profiles[8][3] = "swim Time 18:47";
  Profiles[8][4] = "Cycle Time 21:28";
  Profiles[8][5] = "Running Time 51:12";
  Profiles[8][6] = "Under 18";

  Profiles[9][0] = "Gerald Field";
  Profiles[9][1] = "Female";
  Profiles[9][2] = "Gibraltar";
  Profiles[9][3] = "swim Time 21:02";
  Profiles[9][4] = "Cycle Time 22:50";
  Profiles[9][5] = "Running Time 50:45";
  Profiles[9][6] = "Under 18";

  Profiles[10][0] = "Frank Barnes";
  Profiles[10][1] = "Male";
  Profiles[10][2] = "Gibraltar";
  Profiles[10][3] = "swim Time 19:48";
  Profiles[10][4] = "Cycle Time 26:45";
  Profiles[10][5] = "Running Time 52:34";
  Profiles[10][6] = "Over 18";

  Profiles[11][0] = "Richard Ranking";
  Profiles[11][1] = "Male";
  Profiles[11][2] = "Gibraltar";
  Profiles[11][3] = "swim Time 18:20";
  Profiles[11][4] = "Cycle Time 24:20";
  Profiles[11][5] = "Running Time 56:55";
  Profiles[11][6] = "Over 18";

  Profiles[12][0] = "Deirdre Wilder";
  Profiles[12][1] = "Female";
  Profiles[12][2] = "Gibraltar";
  Profiles[12][3] = "swim Time 22:50";
  Profiles[12][4] = "Cycle Time 27:32";
  Profiles[12][5] = "Running Time 52:23";
  Profiles[12][6] = "Over 18";

  Profiles[13][0] = "Rene Thatcher";
  Profiles[13][1] = "Female";
  Profiles[13][2] = "Gibraltar";
  Profiles[13][3] = "swim Time 20:07";
  Profiles[13][4] = "Cycle Time 22:45";
  Profiles[13][5] = "Running Time 56:32";
  Profiles[13][6] = "Under 18";

  Profiles[14][0] = "Fay Brier";
  Profiles[14][1] = "Female";
  Profiles[14][2] = "Gibraltar";
  Profiles[14][3] = "swim Time 19:42";
  Profiles[14][4] = "Cycle Time 24:09";
  Profiles[14][5] = "Running Time 54:52";
  Profiles[14][6] = "Over 18";

  Profiles[15][0] = "Tom March";
  Profiles[15][1] = "Male";
  Profiles[15][2] = "Gibraltar";
  Profiles[15][3] = "swim Time 18:22";
  Profiles[15][4] = "Cycle Time 23:31";
  Profiles[15][5] = "Running Time 53:12";
  Profiles[15][6] = "Under 18";

  Profiles[16][0] = "Rene Thatcher";
  Profiles[16][1] = "Female";
  Profiles[16][2] = "Southhampton";
  Profiles[16][3] = "Swim Time 15:52";
  Profiles[16][4] = "Cycle Time 19:50";
  Profiles[16][5] = "Running Time 34:40";
  Profiles[16][6] = "Under 18";

  Profiles[17][0] = "Ellen Palmer";
  Profiles[17][1] = "Female";
  Profiles[17][2] = "Southhampton";
  Profiles[17][3] = "swim Time 15:20";
  Profiles[17][4] = "Cycle Time 21:22";
  Profiles[17][5] = "Running Time 33:27";
  Profiles[17][6] = "Over 18";

  Profiles[18][0] = "Archie McPhadden";
  Profiles[18][1] = "Male";
  Profiles[18][2] = "Southhampton";
  Profiles[18][3] = "swim Time 13:39";
  Profiles[18][4] = "Cycle Time 18:35";
  Profiles[18][5] = "Running Time 34:21";
  Profiles[18][6] = "Under 18";

  Profiles[19][0] = "Fay Brier";
  Profiles[19][1] = "Female";
  Profiles[19][2] = "Southampton";
  Profiles[19][3] = "Swim Time 14:20";
  Profiles[19][4] = "Cycle Time 19:19";
  Profiles[19][5] = "Running Time 31:56";
  Profiles[19][6] = "Over 18";

  Profiles[20][0] = "Amy Chadwick";
  Profiles[20][1] = "Female";
  Profiles[20][2] = "Southampton";
  Profiles[20][3] = "swim Time 13:59";
  Profiles[20][4] = "Cycle Time 17:51";
  Profiles[20][5] = "Running Time 30:12";
  Profiles[20][6] = "Under 18";

  Profiles[21][0] = "Tom March";
  Profiles[21][1] = "Male";
  Profiles[21][2] = "southhampton";
  Profiles[21][3] = "swim Time 13:50";
  Profiles[21][4] = "Cycle Time 18:56";
  Profiles[21][5] = "Running Time 30:54";
  Profiles[21][6] = "Under 18";

  Profiles[22][0] = "Deirdre Wilder";
  Profiles[22][1] = "Female";
  Profiles[22][2] = "Southampton";
  Profiles[22][3] = "swim Time 15:12";
  Profiles[22][4] = "Cycle Time 21:19";
  Profiles[22][5] = "Running Time 34:53";
  Profiles[22][6] = "Over 18";

  Profiles[23][0] = "Gerald Field";
  Profiles[23][1] = "Male";
  Profiles[23][2] = "Southampton";
  Profiles[23][3] = "swim Time 14:54";
  Profiles[23][4] = "Cycle Time 20:55";
  Profiles[23][5] = "Running Time 35:31";
  Profiles[23][6] = "Under 18";

  Profiles[24][0] = "Frank Barnes";
  Profiles[24][1] = "Male";
  Profiles[24][2] = "Bourges";
  Profiles[24][3] = "Swim Time 17:40";
  Profiles[24][4] = "Cycle Time 21:20";
  Profiles[24][5] = "Running Time 51:20";
  Profiles[24][6] = "Over 18";

  Profiles[25][0] = "Richard Ranking";
  Profiles[25][1] = "Male";
  Profiles[25][2] = "Bourges";
  Profiles[25][3] = "Swim Time 13:01";
  Profiles[25][4] = "Cycle Time 20:34";
  Profiles[25][5] = "Running Time 54:47";
  Profiles[25][6] = "Over 18";

  Profiles[26][0] = "Archie McPhadden";
  Profiles[26][1] = "Male";
  Profiles[26][2] = "Bourges";
  Profiles[26][3] = "Swim Time 12:25";
  Profiles[26][4] = "Cycle Time 20:02";
  Profiles[26][5] = "Running Time 49:34";
  Profiles[26][6] = "Under 18";

  Profiles[27][0] = "Amy Chadwick";
  Profiles[27][1] = "Female";
  Profiles[27][2] = "Bourges";
  Profiles[27][3] = "Swim Time 12:21";
  Profiles[27][4] = "Cycle Time 19:59";
  Profiles[27][5] = "Running Time 48:32";
  Profiles[27][6] = "Over 18";

  Profiles[28][0] = "Tom March";
  Profiles[28][1] = "Male";
  Profiles[28][2] = "Bourges";
  Profiles[28][3] = "Swim Time 14:50";
  Profiles[28][4] = "Cycle Time 20:00";
  Profiles[28][5] = "Running Time 48:27";
  Profiles[28][6] = "Under 18";

  Profiles[29][0] = "Ellen Palmer";
  Profiles[29][1] = "Female";
  Profiles[29][2] = "Bourges";
  Profiles[29][3] = "Swim Time 13:56";
  Profiles[29][4] = "Cycle Time 21:30";
  Profiles[29][5] = "Running Time 51:23";
  Profiles[29][6] = "Over 18";

  Profiles[30][0] = "Rene Thatcher";
  Profiles[30][1] = "Male";
  Profiles[30][2] = "Bourges";
  Profiles[30][3] = "Swim Time 14:23";
  Profiles[30][4] = "Cycle Time 21:02";
  Profiles[30][5] = "Running Time 52:44";
  Profiles[30][6] = "Under 18";

  Profiles[31][0] = "Gerald Field";
  Profiles[31][1] = "Male";
  Profiles[31][2] = "Bourges";
  Profiles[31][3] = "Swim Time 14:01";
  Profiles[31][4] = "Cycle Time 26:59";
  Profiles[31][5] = "Running Time 50:05";
  Profiles[31][6] = "Under 18";




  for (int row = 0; row < Profiles.length; row++)
  {
     System.out.println("here ");
     for (int column = 0; column < 1; column++)
     {
        System.out.println('\t' + Profiles[row][column] + '\t');
     }
  }

} }

1 个答案:

答案 0 :(得分:1)

您尝试在此数组中分配32个索引值,但您将其大小定义为String[9][7]

请尝试此声明:

String Profiles[][] = new String[32][7];