title: How to print user input in catch block or outside of catch block . User input is taken inside try block
body: <p><em>Hi experts i am new to java programming ,apology if i am not able to explain my doubt clearly. This is practice question of hackerrank</em></p>
  <p>Problem statement : take user input as number and classify it as it fit inside byte,short,int and long.</p>
  <p>Input varaible T --&gt; Number of test cases. n -&gt; user input number, Below is my code
  also to remove <code>NumberFormatException</code> i used try-catch , i guess problem is at try-catch</p>
  <pre><code>    import java.io.*;
  
  public class Solution {
      public static void main(String args[])throws IOException {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          int T = Integer.parseInt(br.readLine());
          byte byteMin = -128;
              byte byteMax = 127;
              short shortMin = -32768;
              short shortMax =  32767;
              int intMin = -(int)Math.pow(2,31);
              int intMax = (int)Math.pow(2,31) -1 ;
              long longMin = -(long)Math.pow(2,63);
              long longMax = (long)Math.pow(2,63) -1 ; 
          while(T-- != 0) {
              int n;
              try {
              n = Integer.parseInt(br.readLine());
              }
              catch(NumberFormatException ex) {
                  System.out.println(n+&quot; can't be fitted anywhere.&quot;);
              }
              System.out.println(n+&quot; can be fitted in:&quot;);
              if(n &gt; byteMin &amp;&amp; n &lt; byteMax) {
                  System.out.println(&quot;* byte&quot;);
              }
              if(n &gt; shortMin &amp;&amp; n &lt; shortMax) {
                  System.out.println(&quot;* short&quot;);
              }
              if(n &gt; intMin &amp;&amp; n &lt; intMax) {
                  System.out.println(&quot;* int&quot;);
              }
              if(n &gt; longMin &amp;&amp; n &lt; longMax) {
                  System.out.println(&quot;* long&quot;);
              }
          }
      }
  }
  </code></pre>
  <p>Below was the input for the above code</p>
  <pre><code>5
  -150
  150000
  1500000000
  213333333333333333333333333333333333
  -100000000000000
  </code></pre>
  <p>When i run it , it gave me variable <code>n</code> not defined. But when i defined variable <code>n = 0 or -1</code> below was the output.</p>
  <pre><code>  -150 can be fitted in:
      * short
      * int
      * long
      150000 can be fitted in:
      * int
      * long
      1500000000 can be fitted in:
      * int
      * long
      -1 can't be fitted anywhere.
      -1 can be fitted in:
      * byte
      * short
      * int
      * long
      -1 can't be fitted anywhere.
      -1 can be fitted in:
      * byte
      * short
      * int
      * long
  </code></pre>
  <p>And the output i need is as below</p>
  <pre><code>   -150 can be fitted in:
      * short
      * int
      * long
      150000 can be fitted in:
      * int
      * long
      1500000000 can be fitted in:
      * int
      * long
      213333333333333333333333333333333333 can't be fitted anywhere.
      -100000000000000 can be fitted in:
      * long
  </code></pre>
  <p>What is going here in code when i assign a value to <code>n as 0 or -1</code> can you explain it and how to solve this?</p>