Returns the max number in the numbers list using TreeSet. - Java java.util

Java examples for java.util:TreeSet

Description

Returns the max number in the numbers list using TreeSet.

Demo Code


//package com.java2s;
import java.math.BigDecimal;

import java.util.List;
import java.util.TreeSet;

public class Main {

    /**/*  w ww  .  j a va2 s  .  c om*/
     * Returns the max number in the numbers list.
     *
     * @param numbers the numbers to calculate the max.
     * @return the max number in the numbers list.
     */
    public static BigDecimal max(List<BigDecimal> numbers) {
        return new TreeSet<BigDecimal>(numbers).last();
    }
}

Related Tutorials