Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions src/main/java/com/thealgorithms/maths/FindMin.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
package com.thealgorithms.maths;

import java.util.Arrays;
import java.util.Random;

public class FindMin {

/**
* Driver Code
*/
public static void main(String[] args) {
Random random = new Random();

/* random size */
int size = random.nextInt(100) + 1;
int[] array = new int[size];

/* init array with random numbers */
for (int i = 0; i < size; i++) {
array[i] = random.nextInt() % 100;
}

assert Arrays.stream(array).min().getAsInt() == findMin(array);
public final class FindMin {
private FindMin() {
}

/**
Expand All @@ -30,7 +11,7 @@ public static void main(String[] args) {
* @exception IllegalArgumentException input array is empty
* @return the mimum value stored in the input array
*/
public static int findMin(int[] array) {
public static int findMin(final int[] array) {
if (array.length == 0) {
throw new IllegalArgumentException("array must be non-empty.");
}
Expand Down