Issue
I need a collection of 64-bit floating point random numbers, and they should be distinct. Is there a library routine for this, or should I manually search for duplicates?
It is actually more important to have the numbers not being closer than some very small constant \epsilon. Is there a library routine for that as well?
Solution
You may use streams
for that.
double[] array = new Random().doubles()
.distinct()
.limit(500) // How many you want.
.toArray();
Answered By - Yassin Hajaj
Answer Checked By - Katrina (JavaFixing Volunteer)