我需要创建一个函数,它返回-1和1之间的随机double值,但不确定执行此操作的逻辑,因此任何帮助都将是最受欢迎的.
Random rng = new Random(); // to get a double between -1 and 1 return rng.nextDouble() * 2 - 1; // rng.nextDouble() is between 0 and 1