title: Java reverse an int value without using array
body: <p>Can anyone explain to me how to reverse an integer without using array or String. I got this code from online, but not really understand why + input % 10 and divide again.</p>
  
  <pre><code>while (input != 0) {
      reversedNum = reversedNum * 10 + input % 10;
      input = input / 10;   
  }
  </code></pre>
  
  <p>And how to do use this sample code to reverse only odd number. Example I got this input 12345, then it will reverse the odd number to output 531.</p>