I'm taking a look at "http://docs.oracle.com/javase/7/docs/api/" for class {String}; I've scrolled down a ways; I see under label "valueOf":
| public static String valueOf(char[] data,
| int offset,
| int count)
|
| Returns the string representation of a specific subarray of the char array argument.
|
| The offset argument is the index of the first character of the subarray. The count argument
| specifies the length of the subarray. The contents of the subarray are copied; subsequent
| modification of the character array does not affect the newly created string.
|
| Parameters:
|
| data - the character array.
|
| offset - the initial offset into the value of the String.
|
| count - the length of the value of the String.
|
| Returns
|
| a string representing the sequence of characters contained in the subarray of the character
| array argument.
|
| Throws:
|
| IndexOutOfBoundsException - if offset is negative, or count is negative, or offset+count is
| larger than data.length.
Then immediately below that under label "copyValueOf" I see:
| public static String copyValueOf(char[] data,
| int offset,
| int count)
|
| Returns a String that represents the character sequence in the array specified.
|
| Parameters:
|
| data - the character array.
|
| offset - initial offset of the subarray.
|
| count - length of the subarray.
|
| Returns:
|
| a String that contains the characters of the specified subarray of the character array.
What exactly is the difference between these two methods, {valueOf()} and {copyValueOf()}? It looks to me like they return precisely the same thing given the same arguments. Am I missing something?
Kevin S
| public static String valueOf(char[] data,
| int offset,
| int count)
|
| Returns the string representation of a specific subarray of the char array argument.
|
| The offset argument is the index of the first character of the subarray. The count argument
| specifies the length of the subarray. The contents of the subarray are copied; subsequent
| modification of the character array does not affect the newly created string.
|
| Parameters:
|
| data - the character array.
|
| offset - the initial offset into the value of the String.
|
| count - the length of the value of the String.
|
| Returns
|
| a string representing the sequence of characters contained in the subarray of the character
| array argument.
|
| Throws:
|
| IndexOutOfBoundsException - if offset is negative, or count is negative, or offset+count is
| larger than data.length.
Then immediately below that under label "copyValueOf" I see:
| public static String copyValueOf(char[] data,
| int offset,
| int count)
|
| Returns a String that represents the character sequence in the array specified.
|
| Parameters:
|
| data - the character array.
|
| offset - initial offset of the subarray.
|
| count - length of the subarray.
|
| Returns:
|
| a String that contains the characters of the specified subarray of the character array.
What exactly is the difference between these two methods, {valueOf()} and {copyValueOf()}? It looks to me like they return precisely the same thing given the same arguments. Am I missing something?
Kevin S