Java Array Min Value minIndex(float[] xs)

Here you can find the source of minIndex(float[] xs)

Description

min Index

License

Apache License

Declaration

public static int minIndex(float[] xs) 

Method Source Code

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

public class Main {
    public static int minIndex(float[] xs) {
        if (xs == null)
            throw new RuntimeException("Received null input");
        if (xs.length == 0)
            throw new RuntimeException("Receveid empty array input");

        int minIdx = -1;
        float minVal = Float.MAX_VALUE;
        for (int i = 0; i < xs.length; ++i) {
            if (xs[i] < minVal) {
                minVal = xs[i];/*from  w  w w  . j a va  2  s .  c  o m*/
                minIdx = i;
            }
        }

        return minIdx;
    }
}

Related

  1. minIndex(double[][] matrix, int column)
  2. minIndex(final double[] array)
  3. minIndex(final double[] values)
  4. minIndex(float[] arr)
  5. minIndex(float[] vals)
  6. minIndex(int[] array)
  7. minIndex(int[] from)
  8. minIndex(int[] ints)
  9. minIndex(int[] values)