title: How exactly does String.split() method in Java work when regex is provided?
body: <p>I'm preparing for OCPJP exam and I ran into the following example:</p>
  
  <pre><code>class Test {
     public static void main(String args[]) {
        String test = "I am preparing for OCPJP";
        String[] tokens = test.split("\\S");
        System.out.println(tokens.length);
     }
  }
  </code></pre>
  
  <p>This code prints 16. I was expecting something like no_of_characters + 1. Can someone explain me, what does the split() method actually do in this case?  I just don't get it...</p>