title: Get input from console in java
body: <p>I used the following code segment to get 10 inputs from console in java and tried to print them for example in <code>*******12</code> format. In run-time, I entered 12,13,14,15 as inputs and then  the program terminated. Now there are 3 questions:</p>
  
  <ol>
  <li>Why this code gets only 5 inputs instead 10?</li>
  <li>Why this code prints for example 49,52,10 for input 14?</li>
  <li>What's the solution?</li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>public static void main(String[] args) {
      for (int i = 0 ; i &lt;10 ;i++){
          try {
              int j= System.in.read();
              System.out.println("**********"+j);
          } catch (IOException ex) {
              ex.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>and the output was:</p>
  
  <pre><code>12
  **********49
  **********50
  **********10 13
  **********49
  **********51
  **********10 14
  **********49
  **********52
  **********10 15
  **********49
  </code></pre>
  
  <p>BUILD SUCCESSFUL (total time: 14 seconds)</p>