Unable to display String values after splitting
<p>I was writing a sample code that splits a given string based on the delimiter and displays the final set of strings. Here is my code-</p>

<pre><code>        String[] arr = null;
        String[] newArr = null;
        String strArr = "adg$dgsd$$$brr$dhr$$$ce$twt$$$dttgdf$gdfg$$$$$";
        for (int i = 0; i &lt; strArr.length(); i++) {
            newArr = strArr.split("\\$\\$\\$\\$");
            for (int j = 0; j &lt; newArr.length; j++) {
                arr = newArr[j].split("\\$\\$");
            }
        }
        System.out.println(strArr);
        System.out.println(newArr[0]);
        System.out.println(arr[0]);
        System.out.println(arr[1]); // throwing exception here
        System.out.println(arr[2]);
        System.out.println(arr[3]);
</code></pre>

<p>And this is the output I got-</p>

<pre><code>adg$dgsd$$$brr$dhr$$$ce$twt$$$dttgdf$gdfg$$$$$
adg$dgsd$$$brr$dhr$$$ce$twt$$$dttgdf$gdfg

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at ArraySplit.main(ArraySplit.java:20)
</code></pre>

<p>This is the output i was expecting-</p>

<pre><code>$adg$dgsd$$$brr$dhr$$$ce$twt$$$dttgdf$gdfg$$$$$
$adg$dgsd$$brr$dhr$$ce$twt$$dttgdf$gdfg
$adg$dgsd
$brr$dhr
$ce$twt
$dttgdf$gdfg$
</code></pre>

<p>What I observed was, if there are 2 $ signs, since its the same as the delimiter pattern, it works fine. But as there are 3 $ signs in between, I am not able to display the rest of the String objects. Any idea on how to tackle this? (extra info: I am actually using this as part of passing a part of the string as password in PostGreSQL)</p>
