title: String index out of bounds exception (charAt)
body: <p>I have an example code:</p>
  
  <pre><code>while (reader.hasNext()) {
              String example = reader.nextLine();
              if (example.charAt(0) == '.') {
                  break;
              } else {
                  if (test(example)) {
                      System.out.println("ok");
                  } else {
                      System.out.println("no");
                  }
              }
          }
  </code></pre>
  
  <p>When I run it, I got a notice</p>
  
  <p>Input:</p>
  
  <pre><code>It's an example.
  
  aabb ccdd.
  .
  .
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Exception in thread "main" 
  java.lang.StringIndexOutOfBoundsException: String index out of range: 0
      at java.lang.String.charAt(Unknown Source)
  </code></pre>
  
  <p>How can I fix that?</p>