File tree Expand file tree Collapse file tree 1 file changed +3
-22
lines changed
src/main/java/com/thealgorithms/maths Expand file tree Collapse file tree 1 file changed +3
-22
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .maths ;
22
3- import java .util .Arrays ;
4- import java .util .Random ;
5-
6- public class FindMin {
7-
8- /**
9- * Driver Code
10- */
11- public static void main (String [] args ) {
12- Random random = new Random ();
13-
14- /* random size */
15- int size = random .nextInt (100 ) + 1 ;
16- int [] array = new int [size ];
17-
18- /* init array with random numbers */
19- for (int i = 0 ; i < size ; i ++) {
20- array [i ] = random .nextInt () % 100 ;
21- }
22-
23- assert Arrays .stream (array ).min ().getAsInt () == findMin (array );
3+ public final class FindMin {
4+ private FindMin () {
245 }
256
267 /**
@@ -30,7 +11,7 @@ public static void main(String[] args) {
3011 * @exception IllegalArgumentException input array is empty
3112 * @return the mimum value stored in the input array
3213 */
33- public static int findMin (int [] array ) {
14+ public static int findMin (final int [] array ) {
3415 if (array .length == 0 ) {
3516 throw new IllegalArgumentException ("array must be non-empty." );
3617 }
You can’t perform that action at this time.
0 commit comments