FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
StreamsAPI-Tutorials/StreamExamples/SecureRandomstream.java at main · CodeJamm/StreamsAPI-Tutorials · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
CodeJamm
/
StreamsAPI-Tutorials
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
StreamsAPI-Tutorials
/
StreamExamples
/
SecureRandomstream.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 897 Bytes
Breadcrumbs
StreamsAPI-Tutorials
/
StreamExamples
/
SecureRandomstream.java
Copy path
File metadata and controls
26 lines (21 loc) · 897 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
StreamExamples
;
import
java
.
security
.
SecureRandom
;
import
java
.
util
.
List
;
import
java
.
util
.
stream
.
Collectors
;
public
class
SecureRandomstream
{
public
static
void
main
(
String
[]
args
)
{
//To get the stream of secure random numbers (i.e. cryptographically strong random number), use subclass SecureRandom.
SecureRandom
random
=
new
SecureRandom
();
//Five random integers
random
.
ints
(
5
).
sorted
().
forEach
(
e
->
System
.
out
.
print
(
e
+
" "
));
System
.
out
.
println
();
//Five random doubles between 0 (inclusive) and 0.5 (exclusive)
random
.
doubles
(
5
,
0
,
0.5
).
sorted
().
forEach
(
e
->
System
.
out
.
print
(
e
+
" "
));
System
.
out
.
println
();
//Boxing long to Long so they can be collected
List
<
Long
>
longs
=
random
.
longs
(
5
).
boxed
().
collect
(
Collectors
.
toList
() );
System
.
out
.
println
(
longs
);
}
}
Back
|
FazBrowse Home
|
New Git URL