title: Java Using Scanner Multiple Times
body: <p>I am having this problem a lot. When I use a Scanner a lot of times, it doesn't get input from user.</p>
  
  <pre><code>Scanner scan = new Scanner(System.in);
  
          System.out.println("1---");
  
          int try1 = scan.nextInt();
  
          System.out.println("2---");
  
          int try2 = scan.nextInt();
  
          System.out.println("3---");
  
          String try3 = scan.nextLine();
  
          System.out.println("4---");
  
          String try4 = scan.nextLine();
  </code></pre>
  
  <p>When I run this code, result it : </p>
  
  <p>1---</p>
  
  <p>12</p>
  
  <p>2---</p>
  
  <p>321</p>
  
  <p>3---</p>
  
  <p>4---</p>
  
  <p>aa</p>
  
  <p>As you can see, it skipped at 3rd input. Why this is happening? I solve this problem by using new Scanners, sometimes I have 5-6 different Scanners and it looks so complicated.
  Another problem is : there is an error "Resource leak: scan is never closed". I am really confused.</p>