title: hasNextInt does not solve Exception in thread "main" java.util.NoSuchElementException
body: <pre><code>import java.io.*;
  
  import java.util.Scanner;
  
  public class TestClass {
  
       public static void main(String[] args) { 
  
        int t;
        Scanner ip = new Scanner(System.in);
        ScoreCalculation ob = new ScoreCalculation();
        t=ip.nextInt();
        ob.score(t); }
  }
  
  class ScoreCalculation {
  
    void score(int t)
    {  
  
      Scanner ipu=new Scanner(System.in);
      int i,cum1=0,cum2=0,lead1=0,lead2=0,one,two;
       for(i=1;i&lt;=t;i++)
      {
         //if(ipu.hasNextInt())
         one=ipu.nextInt();
         //if(ipu.hasNextInt())
         two=ipu.nextInt();
         cum1+=one;
         cum2+=two;
         if(cum1&gt;cum2)
         {
            if(lead1&lt;(cum1-cum2))
            lead1=(cum1-cum2);
  
         }
         else
         {
         if(lead2&lt;(cum2-cum1))
            lead2=(cum2-cum1); 
         }
      }
      if(lead1&gt;lead2)
      System.out.println("1 "+lead1);
      else
      System.out.println("2 "+lead2);
  
    }
  }
  </code></pre>
  
  <p>here is my code when i convert to hasNextInt it still shows error 
  the TestClass name and use of two classes is must</p>
  
  <p>the error is</p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
  
      at java.util.Scanner.throwFor(Scanner.java:862)
  
      at java.util.Scanner.next(Scanner.java:1485)
  
      at java.util.Scanner.nextInt(Scanner.java:2117)
  
      at java.util.Scanner.nextInt(Scanner.java:2076)
  
      at ScoreCalculation.score(TestClass.java:20)
  
      at TestClass.main(TestClass.java:9)
  </code></pre>
  
  <p>the error with hasint</p>
  
  <pre><code>TestClass.java:20: error: incompatible types: boolean cannot be converted to int
  
         one=ipu.hasNextInt();
  
                           ^
  
  TestClass.java:22: error: incompatible types: boolean cannot be converted to int
  
         two=ipu.hasNextInt();
  </code></pre>