Is this method faster than Math.random()?
问题 I am a beginner and have currently started working on a game for Android which uses a particle swarm optimization algorithm. I am now trying to optimize my code a little and i have quite a lot of Math.random() in for-loops which is running almost all the time. So i was thinking of a way to get around and skip all the Math.random() calls. By using a method like this: float random[] = new float[100]; static int randomIndex=0; private float myRandom(){ if(randomIndex >= 99) randomIndex = 0; else