title: How to add multiple characters to one index in a Char Array?
body: <p>Im currently trying to create a function where my input is a string such as "AABBCCDDEE" and the function outputs a String array "AA""BB""CC" and so on. </p>
  
  <pre><code>    public static char[] stringSplitter(final String input) {
  
              String[] strarray = new String[input.length()];
              if (input == null) {
                  return null;
              }
              char[] chrarray = input.toCharArray();
              char[] outputarray = new char[input.length()];
              int j = 0;
              for (int i = 0; i &lt; chrarray.length; i++) {
                  char chr = chrarray[i];
                  System.out.print(chr);
                  outputarray[j] = chrarray[i]; //here i need to find a way to add the characters to the index at j if the preceding characters are equal
                  if (i + 1 &lt; input.length() &amp;&amp; chrarray[i + 1] != chr) {
                      j++;
                      outputarray[j] = chrarray[i + 1];
                      System.out.println(" ");
                  }
              }
  }
  </code></pre>