Java List Max max(final List aList, final Double aDefalut)

Here you can find the source of max(final List aList, final Double aDefalut)

Description

max

License

Apache License

Declaration

public static Double max(final List<Double> aList, final Double aDefalut) 

Method Source Code

//package com.java2s;
/**/*w  ww  .  java 2  s .c  o m*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

public class Main {

    public static Double max(final List<Double> aList, final Double aDefalut) {
        Double max = aDefalut;
        if (null != aList) {
            for (Double value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Float max(final List<Float> aList, final Float aDefault) {
        Float max = aDefault;
        if (null != aList) {
            for (Float value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Integer max(final List<Integer> aList, final Integer aDefalut) {
        Integer max = aDefalut;
        if (null != aList) {
            for (Integer value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Long max(final List<Long> aList, final Long aDefault) {
        Long max = aDefault;
        if (null != aList) {
            for (Long value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }
}

Related

  1. getMaxSize(final List list)
  2. getMaxStrWidth(List list)
  3. getMaxValIndex(List vals)
  4. getMaxValue(List list)
  5. getMaxValue(List values)
  6. max(List values)
  7. max(List a, List b)
  8. max(List booleans)
  9. max(List a)