好的,我对 java 还很陌生,我真的需要一些帮助!我有一个名为的类Teams
,并且已经有一个先前建立的类,但现在我需要使用中列出List <Teams> checkedInTeams;
的特定数据成员填充 2d 数组。我试过了,我不知道该去哪里。Teams
checkedInTeams
temp = checkedInTeams.listIterator(0).getTeamNum();
好的...我想我可能已经解决了一些问题,但是该函数正在创建解析错误,我不确定如何继续:
public void setMatchList(int[][] matchList) {
for (int i = 0; i < numOfMatches; i++)
for (Team team : checkedInTeams)
{
if (i == 1){
if (checkedInTeams.indexOf(team)== 0)
this.matchList[i][checkedInTeams.size()-1] = team.getTeamNum();
}
if (i == 2){
if (checkedInTeams.indexOf(team)== 0)
this.matchList[i][checkedInTeams.size()-2] = team.getTeamNum();
if (checkedInTeams.indexOf(team)== 1)
this.matchList[i][checkedInTeams.size()-1] = team.getTeamNum();
}
if (i == 3){
if (checkedInTeams.indexOf(team)== 0)
this.matchList[i][checkedInTeams.size()-3] = team.getTeamNum();
if (checkedInTeams.indexOf(team)== 1)
this.matchList[i][checkedInTeams.size()-2] = team.getTeamNum();
if (checkedInTeams.indexOf(team)== 2)
this.matchList[i][checkedInTeams.size()-1] = team.getTeamNum();
}
this.matchList[i][checkedInTeams.indexOf(team)-i] = team.getTeamNum();
}
}
好的,希望新问题更好,因为我相信我想出了如何完成我的第一个问题,上面的代码是我最近的尝试。基本上,我正在尝试使用对象的特定数据成员,使用特定对象的列表来填充二维数组。当我填充数组时,我试图创建一个轻微的滑动窗口效果......我希望这不会令人困惑。