如何将二维数组中的一个参数设置为单个数组?

时间:2017-10-26 19:19:55

标签: java eclipse

我想知道如何将2D数组的行设置为单个数组中的第一个元素,将列设置为第二个元素

/**
 * findHighestLocation finds the row and column indexes of the
 * highest value in the given two dimensional array.
 * @param table The two dimensional array for which to find 
 *              the highest value
 * @return a newly created one dimensional array of size 2. The
 *         first element contains the row index of the highest value 
 *         in table. The second element contains the column index
 *         of the highest value in table. */
public static int[] findHighestLocation(int[][] table) {
    int [] highestLocation = new int [2];
    int largest = table[0][0];

    for (int i = 0; i < table.length; i++)
    {
        if (table[i][i] > largest)
        {
            largest = table[i][i];
            highestLocation [0] = table[i][];
            highestLocation [1] = table[i][];
        }
    }
    return highestLocation;
}

0 个答案:

没有答案