title: Run-time error on usage of Integer.parseInt()
body: <p>I was trying to solve a problem to flip two input integers and add the resultant. The obvious way to do this would be by taking modulo and thus getting each digit and reconstructing it back, but I wanted to convert the integers to a string, thus rendering it easy to be flipped, and then reconverting it back to the int, adding it and returning answer.</p>
  
  <p>Code:</p>
  
  <pre><code>import java.util.*;
  
  
      class TestClass {
      public static void main(String args[] ) throws Exception {
      /*
       * Read input from stdin and provide input before running
       * Use either of these methods for input
  
      //BufferedReader
      BufferedReader br = new BufferedReader(new      InputStreamReader(System.in));
      String line = br.readLine();
      int N = Integer.parseInt(line);
      */
      //Scanner
      Scanner s = new Scanner(System.in);
      int N = s.nextInt();
      String num1= " ";
      String modnum1= " ";
      String num2= " ";
      String modnum2= " ";
      int s1=0;
      int s2=0;
      while (N!=0)
      {
          int x=s.nextInt();
          int y=s.nextInt();
          //System.out.println(x+" "+y);
          num1=Integer.toString(x);
          num2=Integer.toString(y);
          for (int i=(num1.length()-1); i&gt;=0; i--)
          {
              modnum1=modnum1 + num1.charAt(i);
          }
          //System.out.println(modnum1);
         // for (int j=(num1.length()-1); j&gt;=0; j--)
          //{
            //  modnum2=modnum2 + num2.charAt(j);
          //}
  
          s1=Integer.parseInt(modnum1);
          System.out.println(s1);
          }
  
          N--;
      }
  
      //System.out.println("Hello World!");
  }
  </code></pre>
  
  <p>This is the error I am getting:</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: " 543"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:569)
      at java.lang.Integer.parseInt(Integer.java:615)
      at chiller.main(chiller.java:40)
  </code></pre>
  
  <p>Line 40 is the line where I'm using <code>parseInt</code>. I used the <code>.trim()</code> hack too, but it still doesn't work.</p>