Error java.lang.ArrayIndexOutOfBoundsException:2 : <p>I am facing java.lang.ArrayIndexOutOfBoundsException.... But my String includes more than 2 values   </p>

<pre><code>  String[] elements = { "Allama Iqbal","born","in","Sailkot"};

 String str = String.join(",", elements); 

           String str = String.join(",", elements);
String[] strArray = new String[] {str};
          if(strArray[2].equals("NNP") ) {
}

The POS are...Allama//NNP
The POS are...Iqbal//NNP
The POS are...,//,
The POS are...born//VBN
The POS are...,//,
The POS are...in//IN
The POS are...,//,
The POS are...Sailkot//NNP
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
</code></pre>
