public static char[] cloneCharArray(char[] chars){
  if (chars == null) {
    return null;
  }
  int len=chars.length;
  if (len == 0) {
    return chars;
  }
  char[] copy=new char[len];
  System.arraycopy(chars,0,copy,0,len);
  return copy;
}

public static char [ ] cloneCharArray ( char [ ] chars ) { if ( chars == null ) { return null ; } int len = chars . length ; if ( len == 0 ) { return chars ; } char [ ] copy = new char [ len ] ; System . arraycopy ( chars , 0 , copy , 0 , len ) ; return copy ; }
create a new char array and copy all the data . if the size of the byte array is zero , the same array is returned .
