FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
StreamsAPI-Tutorials/StreamExamples/InfiniteStream.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
/
InfiniteStream.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (23 loc) · 834 Bytes
Breadcrumbs
StreamsAPI-Tutorials
/
StreamExamples
/
InfiniteStream.java
Copy path
File metadata and controls
27 lines (23 loc) · 834 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
package
StreamExamples
;
import
java
.
util
.
List
;
import
java
.
util
.
Random
;
import
java
.
util
.
stream
.
Collectors
;
import
java
.
util
.
stream
.
Stream
;
import
StudentClass
.
Student
;
public
class
InfiniteStream
{
public
static
void
main
(
String
[]
args
)
{
//Infinite stream of random numbers
List
<
Integer
>
randomNumbers
=
Stream
.
generate
(() -> (
new
Random
()).
nextInt
(
100
))
.
limit
(
10
).
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
randomNumbers
);
//infinite stream of Custom Objects
List
<
Student
>
students
=
Stream
.
generate
(
Student
::
create
)
.
limit
(
5
).
collect
(
Collectors
.
toList
());
for
(
Student
student
:
students
)
{
System
.
out
.
println
(
"Student ID : "
+
student
.
getID
()+
" , Student Name : "
+
student
.
getName
());
}
}
}
Back
|
FazBrowse Home
|
New Git URL