-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
43 lines (33 loc) · 1.75 KB
/
Copy pathSolution.java
File metadata and controls
43 lines (33 loc) · 1.75 KB
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
36
37
38
39
40
41
42
43
//All things that the Father hath are mine: therefore said I, that he shall take of mine, and shall shew it unto you. (John 16:15)
package com.javarush.task.task28.task2803;
import java.util.concurrent.ThreadLocalRandom;
/*
ThreadLocalRandom
*/
public class Solution {
public static int getRandomIntegerBetweenNumbers(int from, int to)
{
return ThreadLocalRandom.current().nextInt(from, to);
}
public static double getRandomDouble() {
return ThreadLocalRandom.current().nextDouble(0,1);
}
public static long getRandomLongBetween0AndN(long n) {
return ThreadLocalRandom.current().nextLong(0, n);
}
public static void main(String[] args) {
}
}
/*
ThreadLocalRandom
Класс Solution будет использоваться трэдами.
Реализуй логику всех методов, используйте класс ThreadLocalRandom.
getRandomIntegerBetweenNumbers должен возвращать случайный int между from и to.
getRandomDouble должен возвращать случайный double.
getRandomLongBetween0AndN должен возвращать случайный long между 0 и n.
Требования:
1. В классе Solution должны быть только статические методы.
2. Метод getRandomIntegerBetweenNumbers с помощью ThreadLocalRandom должен возвращать случайный int между from и to.
3. Метод getRandomDouble с помощью ThreadLocalRandom должен возвращать случайный double от 0 до 1.
4. Метод getRandomLongBetween0AndN с помощью ThreadLocalRandom должен возвращать случайный long между 0 и n.
*/