Java function to split an array into chunks of equal size. The last chunk may be smaller than the rest.