'Why this .split resulting in array out of bound error? [duplicate]

public class test {
    public static void main(String[] args) {        
        String[] arr = {"0 1.2.3.4","a b.c.d.e"};
        System.out.println(arr[0].split(".")[2]);
    }
}

I am using java 8.

the expected output is 3.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source