title: Delimiter in Scanner Java confusion
body: <p>According to Java API Scanner uses delimiters to break the whole input into tokens. I am trying to understand the tokens and delimiters. I was doing this program and hit a confusion</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Test {
      public static void main(String[] args) {
          Scanner s = null;
          try {
              s = new Scanner(System.in);
              s.useDelimiter("A");
              System.out.println("1 " + s.next().length());
              System.out.println("2 " + s.next().length());
              System.out.println("3 " + s.next().length());
              System.out.println("4 " + s.next().length());
          } finally {
              if (s != null) {
                  s.close();
              }
          }
      }
  }
  </code></pre>
  
  <p>When I use the input <code>AAAAAasdf</code> I get the following output.</p>
  
  <pre><code>1 0
  2 0
  3 0
  4 0
  </code></pre>
  
  <p>I can understand this output as the length of tokens is zero between the delimiters hence all are zero but when I use the default delimiters and give the input as </p>
  
  <p><code>_____aaa\n</code> ->Replace underscore by space and <code>\n</code> by me hitting enter in eclipse console.</p>
  
  <p>For this I am getting the output as </p>
  
  <pre><code>1 3
  </code></pre>
  
  <p>which I cannot understand. I have given 5 spaces so there should be 4 tokens of 0 lengths between them. Why not? What am I missing here?</p>