-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.java
33 lines (29 loc) · 970 Bytes
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.yurii.salimov.lesson04.task06;
import java.util.Random;
/**
* 4.6 Задача
*
* Найти в массиве чисел элементы с наибольшим и
* наименьшим значениями.
*
* @author Yuriy Salimov ([email protected])
*/
public class Main {
public static void main(String[] args) {
final int length = 10;
final int[] array = createRandomArray(length);
final NumberArray numberArray = new NumberArrayImpl(array);
final int min = numberArray.min();
final int max = numberArray.max();
System.out.println("Min = " + min);
System.out.println("Min = " + max);
}
private static int[] createRandomArray(final int length) {
final int[] array = new int[length];
final Random random = new Random();
for (int i = 0; i < length; i++) {
array[i] = random.nextInt();
}
return array;
}
}