FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java_upgrade/src/main/java/RandomDemo.java at main · alcmontejo/java_upgrade · GitHub
alcmontejo
/
java_upgrade
Public
forked from
kousen/java_upgrade
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java_upgrade
/
src
/
main
/
java
/
RandomDemo.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 843 Bytes
Breadcrumbs
java_upgrade
/
src
/
main
/
java
/
RandomDemo.java
Copy path
File metadata and controls
27 lines (24 loc) · 843 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
27
import
java
.
util
.
OptionalInt
;
import
java
.
util
.
Random
;
import
java
.
util
.
stream
.
IntStream
;
public
class
RandomDemo
{
public
static
void
main
(
String
[]
args
) {
Random
r
=
new
Random
();
int
sum
=
IntStream
.
generate
(() ->
r
.
nextInt
(
10
))
.
limit
(
10
)
.
map
(
n
-> {
System
.
out
.
println
(
"n = "
+
n
);
return
n
;
})
.
filter
(
n
->
n
%
2
==
0
)
// only even numbers
.
peek
(
System
.
out
::
println
)
.
map
(
n
->
n
*
2
)
.
sum
();
System
.
out
.
println
(
sum
);
System
.
out
.
println
(
"Filtering integers:"
);
OptionalInt
first
=
IntStream
.
generate
(() ->
r
.
nextInt
(
10
))
.
peek
(
System
.
out
::
println
)
.
filter
(
n
->
n
>
7
)
.
findFirst
();
}
}
Back
|
FazBrowse Home
|
New Git URL