title: How to input an Empty string in JAVA
body: <p>My program should check if s is an empty string and if found so, it should print "Empty string" and prompt for new input. But my every first run without asking for s, prints "Empty String", afterward it runs perfectly! </p>
  
  <pre><code>Scanner input = new Scanner(System.in);
  int t = input.nextInt();
  while (t &gt; 0) {
      String s;
      s = input.nextLine();
      if (s.isEmpty()) {
          System.out.println("Empty string");
          s = input.nextLine();
      } 
  }
  </code></pre>
  
  <p>How can I avoid the first "Empty String"?</p>
  
  <p>PS- I tried -</p>
  
  <pre><code>s = input.next();
  </code></pre>
  
  <p>This solves the problem but now it won't let me input an Empty String into the program!</p>
  
  <p>PPS- Check this out:</p>
  
  <pre><code>import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  class ComparePlayers {
      public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          int t = input.nextInt();
          while (t &gt; 0) {
              String s;
              s = input.nextLine();
              if (s.isEmpty()) {
                  System.out.println("Empty String");
                  s = input.nextLine();
              }
              else {
                  System.out.println("Not Empty");
              }
              t--;
          }
      }
  }
  </code></pre>
  
  <p>You can see there are 3 i/ps while one of the o/ps is taken up by the Empty String.</p>