开发者

storing a value in a parameter

开发者 https://www.devze.com 2023-03-01 08:17 出处:网络
hi please can anyone tell me how to store some int values in an array public int getStatistics(int teamid) {

hi please can anyone tell me how to store some int values in an array

public int getStatistics(int teamid) {
    int stats = 0;

    for(int runid = 0; runid < 4; runid++) {
        stats = teams[teamid].getRunTime(runid);
    }
}

i am writting a method to retrieve the statistics contained for a team in an array location.it contains 4 开发者_JAVA百科values.the team id is an int an is selected by user while the run id brings out the values in each location.my problem is to store the value i have in the stats to a place which can contain for seperate values. example 5,7,8,4


Your question is kinda vague, but it seems like you want your function to generate an array. Based on your code:

public int[] getStatistics(int teamid) {
    int stats = 0;
    int[] ret = new int[4];

    for(int runid = 0; runid < 4; runid++) {
        ret[runid] = teams[teamid].getRunTime(runid);
    }
    return ret;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消