In Java, calculate the maximum and minimum values in List & lt; double [] & gt;, javadouble

Source: Internet
Author: User

In Java, calculate the maximum and minimum values in List <double []>, javadouble

If you need to reprint please indicate the source: http://blog.csdn.net/itas109

QQ technology exchange group: 129518033

 

Reference: http://stackoverflow.com/questions/8093163/min-max-values-of-a-listdouble

 

There is an array as follows, and the maximum and minimum values are obtained.

List<double[]> values = new ArrayList<double[]>();values.add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2,    13.9 });values.add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 });values.add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 });values.add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 });


Maximum value:

public double ListDoubleArrayMax(List<double[]> dataList) {double max = Double.MIN_VALUE;for (double[] ds : dataList) {for (double d : ds) {if (d > max) {max = d;}}}return max;}


 

Minimum value:

public double ListDoubleArrayMin(List<double[]> dataList) {double min = Double.MAX_VALUE;for (double[] ds : dataList) {for (double d : ds) {if (d < min) {min = d;}}}return min;}


 

If you need to reprint please indicate the source: http://blog.csdn.net/itas109

QQ technology exchange group: 129518033

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.