Java ArrayList Max maxLength(ArrayList> a)

Here you can find the source of maxLength(ArrayList> a)

Description

Find the maximum length of any given element in the array.

License

Open Source License

Parameter

Parameter Description
a the array of arrays to find the length of.

Return

the largest length of any array in the list.

Declaration

public static int maxLength(ArrayList<ArrayList<Integer>> a) 

Method Source Code

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

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    /**//from ww w.j a v a 2  s. co  m
     * Find the maximum length of any given element in the array.
     * 
     * @param a
     *            the array of arrays to find the length of.
     * @return the largest length of any array in the list.
     */
    public static int maxLength(ArrayList<ArrayList<Integer>> a) {
        int i = 0;
        for (ArrayList<Integer> e : a)
            i = Math.max(i, e.size());
        return i;
    }

    public static int Max(Collection<Integer> a) {
        int i = 0;
        for (int z : a)
            i = Math.max(i, z);
        return i;

    }

    public static int Max(ArrayList<ArrayList<Integer>> data) {
        int c = 0;
        for (int i = 0; i < data.size(); i++)
            c = Math.max(c, Max(data.get(i)));
        return c;
    }
}

Related

  1. Max(ArrayList> data)
  2. Max(ArrayList values)
  3. maxEltsInOneSetOfValues(ArrayList values)
  4. maxInColumns(ArrayList lines)
  5. maxIntValue(ArrayList ints)
  6. maxLengthSurface(ArrayList value)
  7. maxset(ArrayList a)