-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOTPGeneration.java
More file actions
34 lines (27 loc) · 1.13 KB
/
OTPGeneration.java
File metadata and controls
34 lines (27 loc) · 1.13 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
package lambda;
import java.util.function.Supplier;
public class OTPGeneration {
public static void main(String[] args) {
Supplier<String> otpSupplier = () -> {
char[] chars = {'A','B','C','D','E'};
char startChar = chars[(int) (Math.random() * 4)];
long middleNumber = Math.round(Math.random()*(999 - 100) + 100);
char endchar = chars[(int) (Math.random() * 4)];
return ""+startChar+middleNumber+endchar;
};
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
System.out.println(otpSupplier.get());
}
}