static char[] toCharArray(CharSequence cs) {
        if (cs instanceof String) {
            return ((String) cs).toCharArray();
        } else {
            int sz = cs.length();
            char[] array = new char[cs.length()];
            for (int i = 0; i < sz; i++) {
                array[i] = cs.charAt(i);
            }
            return array;
        }
    }
Green implementation of toCharArray.

@param cs the {@code CharSequence} to be processed
@return the resulting char array
android/android_framework/base/src/main/java/lang3/CharSequenceUtils.java