code: public static final char[] replaceOnCopy(char[] array, char toBeReplaced,
  			char replacementChar)
  	{
  
  		char[] result = null;
  		for (int i = 0, length = array.length; i < length; i++)
  		{
  			char c = array[i];
  			if (c == toBeReplaced)
  			{
  				if (result == null)
  				{
  					result = new char[length];
  					System.arraycopy(array, 0, result, 0, i);
  				}
  				result[i] = replacementChar;
  			} else if (result != null)
  			{
  				result[i] = c;
  			}
  		}
  		if (result == null)
  		{
  			return array;
  		}
  		return result;
  	}
docs: Replace all occurrence of the character to be replaced with the remplacement character in a copy of the given
  array. Returns the given array if no occurrences of the character to be replaced are found. <br>
  <br>
  For example:
  <ol>
  <li>
  
  <pre>
  array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
  toBeReplaced = 'b'
  replacementChar = 'a'
  result =&gt; A new array that is equals to { 'a' , 'a', 'a', 'a', 'a', 'a' }
  </pre>
  
  </li>
  <li>
  
  <pre>
  array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
  toBeReplaced = 'c'
  replacementChar = 'a'
  result =&gt; The original array that remains unchanged.
  </pre>
  
  </li>
  </ol>
  
  @param array
  the given array
  @param toBeReplaced
  the character to be replaced
  @param replacementChar
  the replacement character
  @throws NullPointerException
  if the given array is null