Files
Java/src/main/java/com/thealgorithms/maths/FindMin.java
Abhinav Pandey 152e29034d Improved code readability and code quality (#4663)
* Fixed Small typos :-)

* Update BufferedReader.java

* Made the following changes :

* Improved readability of files and removed gramatical errors.

* Implemented data assigning instead of manually calling arr.ylength in several instances like FindMax, FindMaxRecursion etc.

* Removed unwanted params from several files

* Implemented Math methods in files math/FindMinRecursion.java and FindMaxRecursion.java

* Update src/main/java/com/thealgorithms/maths/FindMinRecursion.java

---------

Co-authored-by: Debasish Biswas <debasishbsws.dev@gmail.com>
2023-10-11 17:29:55 +05:30

27 lines
703 B
Java

package com.thealgorithms.maths;
public final class FindMin {
private FindMin() {
}
/**
* @brief finds the minimum value stored in the input array
*
* @param array the input array
* @exception IllegalArgumentException input array is empty
* @return the mimum value stored in the input array
*/
public static int findMin(final int[] array) {
if (array.length == 0) {
throw new IllegalArgumentException("Array must be non-empty.");
}
int min = array[0];
for (int i = 1; i < array.length; i++) {
if (array[i] < min) {
min = array[i];
}
}
return min;
}
}