title: System.out.printlns error which prints multiple times instead of once? (Java - New info)
body: <p>Basically, this is a loop in which the if input.equals stuff is fine but for the last else if (the bomb one) it for some reason prints out either 2 or 3 or one of that Ouch you got hit, at the same time subtracting 3*how many times it was printed. Why is it doing this and how can I fix it? I think when the tries are subtracted, is it possible it restarts the while loop? Bombs[][] is a two-dim array which stores true and false values to define wether or not there is a bomb there. I am fairly sure the problem is with the setup of the if-else statement though :/ I just figured out that when I add the input.equals(pos[][]) to the last else-if statement, it breaks the printing out of the Ouch message so nothing is printed. When I put in all of the other variables it works but not that one.</p>
  
  <pre><code>boolean[][]bombs = new boolean[10][10];
      while(bombs2&gt;=0)
      {
      for(int a=0; a&lt;=9;a++)
      {
          for(int b=0;b&lt;=9;b++)
          {
              if(bombs2&gt;=0)
              {
              random2 = (int)(Math.random()*100);
              if((random2 == 48) &amp;&amp; tof[a][b] == false)
              {
              bombs[a][b] = true;
              bombs2--;
              }
  
              else
              {
                  bombs[a][b] = false;
              }
             }
          }
      }
      }
  
  int tries = 13;
    while(playing==true &amp;&amp; tries&gt;0)
      {
      Scanner next = new Scanner(System.in);    
      System.out.println("Coordinate: ");
      System.out.println("testing");
      String input = next.nextLine();
      for(int m = 0; m&lt;=9;m++)
      {
          for(int n = 0; n&lt;=9;n++)///Output after each coordinate is guessed.
          {
              if ((input.equals(pos[m][n])) &amp;&amp; tof[m][n] == true &amp;&amp; m == vertcol &amp;&amp; n == horcol &amp;&amp; bombs[m][n] == false)
              {
                  System.out.println("Congratulations! You won the game and found the coordinate!");
                  playing = false;
              }
              else if ((input.equals(pos[m][n])) &amp;&amp; tof[m][n] == false &amp;&amp; m == vertcol &amp;&amp; n!= horcol &amp;&amp; bombs[m][n] == false)
              {
                  System.out.println("Miss, but the square you are looking for is somewhere in this vertical column.");
                  tries--;
              }
              else if ((input.equals(pos[m][n])) &amp;&amp; tof[m][n] == false &amp;&amp; n == horcol &amp;&amp; m!= vertcol&amp;&amp; bombs[m][n] == false)
              {
                  System.out.println("Miss, but the square you are looking for is somewhere in this horizontal column.");
                  tries--;
              }
              else if((input.equals(pos[m][n])) &amp;&amp; tof[m][n] == false &amp;&amp; n!= horcol &amp;&amp; m!= vertcol&amp;&amp; bombs[m][n] == false)
              {
                  System.out.println("Complete Miss.");
                  tries--;
              }
              **else if(bombs[m][n] == true)
              {
                  System.out.println("Ouch! You got hit by a bomb! Minus three tries.");
                  tries -= 3;**
              }
          }
      }
  }
  System.exit(0);
  </code></pre>