title: In a for loop, Println functions make loop cycles forever. Why does it happening?
body: <p>I found some programming exercises but this one didn't solved. Program takes input as integer then sums the amount of prime number you give. Code is to fail I know but while I'm to trying to debug it fount something interesting if I run the commented println functions then loop takes forever and never terminate itself. Can someone explain why?</p>
  
  <pre><code>    static void problem11() {//summing prime numbers
      System.out.println("how many numbers do you want?");
      int aim = scanner.nextInt();
      int count = 0;
      int datum = 2;
      int sum = 0;
      while(count&lt;aim) {
          boolean prime = true;
          for(int i=datum-1; i&gt;=2; i--) {
              **//System.out.println("inside for, datum: " + datum);**
              if(datum%i==0)
                  **//System.out.println(datum +" is not a prime number");**
                  prime = false;
          }
          if(prime) {
              System.out.println("one prime found");
              count++;
              sum += datum;
          }
          datum++;
      }
      System.out.printf("\nSum of first %d prime numbers is: %d", aim, sum);
  }
  </code></pre>
  
  <p>Thanks to @Andy , @MauricePerry , and @Nevexis. Yes I know I should use curly brackets but I'm trying to shorten my code for readability but as a beginner I probably keep on the safe lane.</p>