I do not understand how the `split()` method from String class works when using `regex` (a non-whitespace character). I have found some partial anwsers on the internet but i still don't understand. Here is my code:

```
public class Test {
    public static void main(String[] args) {
        String myX = "x xx ";
        String[] x = myX.split("\\S");

        for (String s : x){
            System.out.print("\"" + s + "\", ");
        }
        System.out.println(x.length);
    }
}

```

My logic is as follows:

Is the first `'x'` a non-whitespace? Yes, so in the array we should have `""`  

Is the `' '` non-whitespace? No, so in the array we should have `" "`  

Is the second `'x'` a non-whitespace? Yes, so in the array we should have `""`  

Is the third `'x'` a non-whitespace? Yes, so in the array we should have `""`  

Is the last `' '` non-whitespace? No, so in the array we should have `" "`  

In my opinion the array should look like this: `["", " ", "", "", " "]`

Why the array looks like `["", " ", "", " "]` and has the length 4 in stead of 5? In the middle are located 2x, not only one as in the array appears.

Thanks!