谁知道java中 toCharArray()方法的原代码?

来源:百度知道 编辑:UC知道 时间:2024/06/13 15:00:41
能否写出来谢谢

/**
* Converts this string to a new character array.
*
* @return a newly allocated character array whose length is the length
* of this string and whose contents are initialized to contain
* the character sequence represented by this string.
*/
public char[] toCharArray() {
char result[] = new char[count];
getChars(0, count, result, 0);
return result;
}

/**
* Copies characters from this string into the destination character
* array.
* <p>
* The first character to be copied is at index <code>srcBegin</code>;
* the last character to be copied is at index <code>srcEnd-1</code>
* (thus the total number of characters to be copied is
* <code>srcEnd-srcBegin</code>). The characters are copied into the
* subarray of <code>dst</code> st