在Java中生成唯一的双重值的最有效方法是什么?

问题描述:

有诸如搜索重复的方法,但我想知道是否有更好的解决方案。

There are methods such as searching for duplicates but I wonder if there is a better solution for this task.

你可以使用

double[] array = new Random().doubles()
                             .distinct()
                             .limit(500) // How many you want.
                             .toArray();