title: Java - Values being changed suddenly and print line statement running twice?
body: <p>I have the following code block:</p>
  
  <pre><code>    } else {
          System.out.println("call");
          int left = solveExpression(leftExpression.toString(), enviornment);
          int right = solveExpression(rightExpression.toString(), enviornment);
          System.out.println(left + "  " + right);
          return left % right;
      }
  </code></pre>
  
  <p>The output of the code is exactly as follows:</p>
  
  <p>call</p>
  
  <p>10  2</p>
  
  <p>12  0</p>
  
  <pre><code>Exception in thread "main" java.lang.ArithmeticException: / by zero
  at PrefixSolver.getOperatorExpression(PrefixSolver.java:245)
  at PrefixSolver.solveExpression(PrefixSolver.java:83)
  at PrefixSolver.parseDefinition(PrefixSolver.java:168)
  at PrefixSolver.parseEnviornment(PrefixSolver.java:122)
  at PrefixSolver.solveExpression(PrefixSolver.java:55)
  at PrefixSolver.parseDefinition(PrefixSolver.java:168)
  at PrefixSolver.parseEnviornment(PrefixSolver.java:122)
  at PrefixSolver.solveExpression(PrefixSolver.java:55)
  at PrefixSolver.getOperatorExpression(PrefixSolver.java:232)
  at PrefixSolver.solveExpression(PrefixSolver.java:83)
  at PrefixSolver.parseDefinition(PrefixSolver.java:168)
  at PrefixSolver.parseEnviornment(PrefixSolver.java:122)
  at PrefixSolver.solveExpression(PrefixSolver.java:55)
  at PrefixSolver.getOperatorExpression(PrefixSolver.java:232)
  at PrefixSolver.solveExpression(PrefixSolver.java:83)
  at PrefixSolver.solve(PrefixSolver.java:12)
  at Prefix.main(Prefix.java:17)
  </code></pre>
  
  <p>I'm very confused how this is even possible. The first println is correct (10 2) but then it is changed somehow?? Just to see if somehow solveExpression is getting called again I put println's in the method and it is not getting called again. The values are just changing somehow..?</p>