I have the array : ['a','b','c','d']
I want to take a certain range of the array, say [0,2]
and make this a string. The result would be "abc"
.
This solution actually works :
private static String convertPartArrayToString(char[] array, int startIndex, int endIndex) {
char[] dest = new char[endIndex - startIndex + 1];
System.arraycopy( array, startIndex, dest, 0, endIndex - startIndex + 1 );
return new String(dest);
}
But isn't there a way to make this faster than to copy the array?