java—如何将构造函数值传递给arraylist?

xam8gpfp  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(235)

我有两个课程,分别是足球俱乐部和英超经理。我想从premierleaguemanagerclass初始化足球构造函数的值。同时,我想将该值集作为数组存储在数组中。outerar下面是我的主arraylist,innerar1是我计划存储构造函数值的数组。

ArrayList<ArrayList<String>> outerAr = new ArrayList<ArrayList<String>>();
ArrayList<String> innerAr1 = new ArrayList<>();

这是我在足球课上的老师。

//constructor 
public FootballClub(String clubName ,int wins, int draws, int defeats, int receivedGoals, int scoredGoals, int points, int playedMatches) {
        super(clubName);
        this.wins = wins;
        this.draws = draws;
        this.defeats = defeats;
        this.receivedGoals = receivedGoals;
        this.scoredGoals = scoredGoals;
        this.points = points;
        this.playedMatches = playedMatches;
    }

这就是我在premierleaguemanager类中初始化构造函数值的方法。

FootballClub fc1 = new FootballClub("team01",1,0,0,5,4,3,1);

现在我的问题是我想把这些值存储在一个数组中。我是java新手,非常感谢您的帮助。我正在使用Java8。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题