I'm coding a function that takes in an ArrayList, then copies each of the char[] into another char[] with added length, then the new char[] is added to a new ArrayList. The error occurs in the line when I try to copy the array. Am I incorrectly using the syntax or is my logic wrong?
public ArrayList<char[]> sort(ArrayList<char[]> chars)
{
ArrayList<char[]> chars2 = new ArrayList<char[]>();
for (int i = 0; i < chars.size(); i++)
{
if (chars.get(i).length < chars.get(i + 1).length)
{
char[] c = chars.get(i).copyOf(chars.get(i), ((chars.get(i + 1).length - chars.get(i).length) + chars.get(i).length));
}
}
return chars2;
}