title: Java: How can I get a deterministic method result when it is launched from a user interface?
body: <p>I'm using java to process simulations,
  If I launch the the simulation from a static main function, everything is deterministic and I get the same simulation each time I hit Run as -&gt; Java application, even if I close and reopen eclipse, which is enough to debug the program.</p>
  <p>But when I launch the simulation from a GUI (with libgdx) with the same parameters multiple times, the result does change each time.</p>
  <p>I Suspect that the code executed during the GUI is not exactly the same (because I am not a robot) which causes some classes such as HashSet to have non deterministic iterations.</p>
  <p>How can I get the same behavior as the static main method?</p>
  <p>Any advice would be much appreciated</p>
  <p>Edit: as code was asked, there is an instance of the issue:</p>
  <pre class="lang-java prettyprint-override"><code>public class Test{
      private static final int n = 4;
      
      public static void main(final String[] args) 
      {
          // random HashSet in my GUI uses Object.hashcode
          for(int i = 0; i &lt; n; i ++)
          {
              new Test().hashCode();
          }
          // at some point launches the simulation
          simulation();
      }
  
      public static void simulation()
      {
          // HashSet anywere in the simulation uses hashcode
          System.out.println(new Test().hashCode());
      }
  }
  </code></pre>
  <p>The result of simulation() depends on n (on what happened during the GUI), so i just would like to get rid of the GUI's influence and run the static method simulation separately, but how?</p>