Pasting this modified expand() to a sketch, there’s no more need to use (cast) over the returned array: ![]()
P.S.: The overridden expand() method needs: import java.util.Arrays; in order to compile.
Alternatively you can prefix java.util. to Arrays.copyOf(list, newSize):
return java.util.Arrays.copyOf(list, newSize);