
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Generate Infinite Stream of Integers in Java Using Random Ints
To generate Infinite Stream of Integers, you can use the Random class and its ints() method
Random.ints()
Here, we have used the ints() method to get the next integer.
The following is an example displaying how to generate Infinite Stream of Integers with Random.ints() in Java
Example
import java.util.stream.*; import java.util.*; public class Demo { public static void main(String[] args) { Random r = new Random(); r.ints().forEach(System.out::println); } }
Output
78799000099 8787879898 2872737888 . . .
Advertisements