title: scanner nextLine() exception: no line found
body: <p>I'm doing the scanner for a static method, and occur this exception:</p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException: No line found
  </code></pre>
  
  <p>My modify method tends to get 2 string as input from the console, but it doesn't work.
  <strong>NOTE:</strong> I didn't use <code>scanner.close();</code></p>
  
  <pre><code>static ArrayList&lt;Book&gt; modBook(){
      Book tempbook = Book.searchTitle();
  
      if(tempbook !=null){
          Scanner sc = new Scanner(System.in);
          int i = BookList.indexOf(tempbook);
  
          System.out.println("Please enter title:");
          String booktitle = sc.nextLine();
          System.out.println("Please enter author:");
          String bookauthor = sc.nextLine();
  
          tempbook.setTitle(booktitle);
          tempbook.setAuthor(bookauthor);
          BookList.set(i, tempbook); 
  
      }
      return BookList;
  }
  </code></pre>
  
  <p>My search method:</p>
  
  <pre><code>static Book searchTitle(){
      try (Scanner input = new Scanner(System.in)) {
          String booktitle;
          System.out.println("Please enter title:");
          booktitle = input.nextLine();
  
          for(Book b : BookList){
              if(b.getTitle() != null &amp;&amp; b.getTitle().equals(booktitle)){
                  System.out.println(b.toString());
                  return (Book) b;
              }
          }        
      }catch(Exception e){e.getMessage(); return null;}
  
      System.out.println("not found");
      return null;
  }
  </code></pre>