title: Why is my code repeating itself while computing?
body: <p><a href="https://i.stack.imgur.com/6XvpJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6XvpJ.png" alt="Compilation" /></a></p>
  <p>When I run my code it outputs the print part 2 times instead of one and I couldnt understand the reason behind it.I think it counts ENTER as a character but ı dont know how to prevent that</p>
  <pre><code>public class DoWhile {
      public static void main(String[] args) throws java.io.IOException {
          char ch;
          do {
              System.out.print(&quot;Press a key followed by ENTER : &quot;);
              ch = (char)System.in.read(); // get a char
          } while (ch != 'q');
  
      }
  }
  </code></pre>