java - How can I loop this and reset the variable -


when try put loop main() method, private 'iterations' variable doesn't seem reset value everytime loop run. need private variable reset orginal value everytime loop incremented.

import java.util.random;  public class randombuster {      //used internally random generate next numbers                                                                                                                                                     private static final long multiplier = 0x5deece66dl;     private static final long addend = 0xbl;     private static final long mask = (1l << 48) - 1;      //the seed. if find seed, can predict 'random' numbers                                                                                                                                         private static long seed;      //the random number busting                                                                                                                                                                       private static random random = new random();      //how many iterations did need?                                                                                                                                                                           private static int iterations = 1;      public static void main(string[] args) {        (int x = 1; x <= 100; x++){         findseed(random.nextint());         system.out.println();          //now know seed, can find next integer                                                                                                                                                    predictnext(32); // calculated seed v1. gets v2                                                                                                                                            system.out.println("predicted nextint: " + predictnext(32));  //predicted v3                                                                                                                                 system.out.println("   random.nextint: " + random.nextint()); //actual v3       }}      protected static synchronized void findseed(long v1) {         long v2 = random.nextint();         (int = 0; < 65536; i++) {             seed = v1 * 65536 + i;             if ((((seed * multiplier + addend) & mask) >>> 16) == v2) {                 system.out.println();                 system.out.println("seed found: " + seed + " in " + iterations + " iterations");                 break;             }             seed = null;         }          //if haven't found yet, loop through again                                                                                                                                                             iterations++;         if (seed == null) findseed(v2);     }      protected static synchronized int predictnext(int bits) {         seed = (seed * multiplier + addend) & mask;         return (int) (seed >>> (48 - bits));     }  } 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -