So I have a string which i'm splitting up in substrings. Everyone of those substrings should become an element of a new String array.

so far I have this:

```
public static void main(String[] args) throws IOException {
    // TODO Auto-generated method stub

    InputStreamReader isr = new InputStreamReader (System.in);
    BufferedReader in = new BufferedReader (isr);

    System.out.println("String: ");
    String s = in.readLine();

    String [] rij = new String [s.length()];

    for (int i = 0; i < s.length(); i++) {      
        if (s.charAt(i) == ' ' || i==0){
            String temp = s.substring(i,s.indexOf(' ',i+1));
            rij [i] = temp;

        }

    }

```

If my input is: "Hello World."
my String array should become {Hello, World.}

```
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -33
    at java.lang.String.substring(String.java:1911)
    at CyclischPermuteren.main(CyclischPermuteren.java:34) 

```

I don't know how to solve this because I can't figure out what I should use as length for my String array since the amount of substring needed to be made is unknown and need to use that string array in a static method later on.