-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
35 lines (30 loc) · 978 Bytes
/
Main.java
File metadata and controls
35 lines (30 loc) · 978 Bytes
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
34
35
package com.yurii.salimov.lesson05.task03;
import java.util.Arrays;
import java.util.Random;
/**
* 5.3 Задача
*
* Написать ф-ю, которая принимает на вход массив чисел и
* возвращает его длину в байтах как результат.
*
* @author Yuriy Salimov (yuriy.alex.salimov@gmail.com)
*/
public class Main {
public static void main(String[] args) {
final int length = 10;
final int[] numbers = randomNumbers(length);
final int size = sizeof(numbers);
System.out.println(size);
}
private static int sizeof(final int[] numbers) {
return numbers.length * 4;
}
private static int[] randomNumbers(final int length) {
final int[] numbers = new int[length];
final Random random = new Random();
for (int i = 0; i < length; i++) {
numbers[i] = random.nextInt();
}
return numbers;
}
}