Java Array Max Value maxRow(Object[]... arr)

Here you can find the source of maxRow(Object[]... arr)

Description

Returns the first row's index having the maximum length in a 2D array.

License

Open Source License

Parameter

Parameter Description
arr a 2D array

Return

the index of the first instance of a longest row

Declaration

public static int maxRow(Object[]... arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w  ww  . java  2s .  com*/
     * Returns the first row's index having the maximum length in a 2D array.
     *
     * @param arr a 2D array
     * @return the index of the first instance of a longest row
     */
    public static int maxRow(Object[]... arr) {
        int maxRowLength = arr[0].length;
        int maxRow = 0;
        for (int i = 1; i < arr.length; i++) {
            if (maxRowLength < arr[i].length) {
                maxRowLength = arr[i].length;
                maxRow = i;
            }
        }

        return maxRow;
    }
}

Related

  1. maxpool(float[] curr, float[] probs)
  2. maxPosition(float[] v)
  3. maxPositive(int[] array)
  4. maxPrim(final int... numbers)
  5. maxRepeating(int[] input, int k)
  6. maxRowLen(Object[]... arr)
  7. maxSize(String[] string)
  8. maxSort(double[] arr)
  9. maxStartFromIndex(double[] array, int startFromIndex)