Java Array Max Value max(float... a)

Here you can find the source of max(float... a)

Description

max

License

Apache License

Declaration

public static float max(float... a) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static float max(float... a) {
        switch (a.length) {
        case 0:// w  w w . java 2 s. c  om
            return Float.NaN;
        case 1:
            return a[0];
        case 2:
            return Math.max(a[0], a[1]);
        case 3:
            return Math.max(a[0], Math.max(a[1], a[2]));
        case 4:
            return Math.max(Math.max(a[0], a[1]), Math.max(a[2], a[3]));
        default: {
            float m = a[0];
            for (int i = 1; i < a.length; i++) {
                if (a[i] > m)
                    m = a[i];
            }
            return m;
        }
        }
    }
}

Related

  1. max(final int[] values)
  2. max(final long[] longs)
  3. max(final Number... numbers)
  4. max(final T p_enum1, final T p_enum2, final T[] enumValues)
  5. max(final T... elements)
  6. max(float... fs)
  7. max(float... fs)
  8. max(float... values)
  9. max(float[] floats)