Scanner not stopping to read input
<p>In order to make my program more streamlined (Without try and catch everywhere), I tried to create a seperate method just for getting data. I have one for Doubles, and Strings, as well.
For some reason, when I try to use this method, it is completely ignored, and passed by like a comment. Is there something I'm doing wrong?</p>

<pre><code>public int inputint(){
     Scanner sc = new Scanner (System.in);
     int variable = 0;
     boolean valid = true;
     do{
        try{
           if (variable &gt;= 0 &amp;&amp; valid){
           }
           else if(valid){
              System.out.print("Please enter positive values only: ");
           }

           valid = true;
        }
           catch (InputMismatchException e){
              System.out.print("Please enter numerical values only: ");
              sc = new Scanner(System.in);
              valid = false;
           }
     }while (!valid || variable &lt; 0);
     return variable;
  }
</code></pre>
