I have a String array with 4 elements. I want to extend this String array with the same elements repeated 3 or n times.
For Example, for the array
String[] array = {"a", "b", "c", "d"};
I want to have something like
String[] array = {"a", "b", "c", "d", "a", "b", "c", "d", "a", "b", "c", "d" };
I tried to something as follows:
String[] columnHeaderNamesArray = {"A","b","c","d"};
String[] extendedColumnHeaderNamesArray = new String[columnHeaderNamesArray.length * 3];
Arrays.fill(extendedColumnHeaderNamesArray, columnHeaderNamesArray);
But I got an ArrayStoreException.
Arrays.fill()doesn't treat you array as actually array, it's considered as object. So, you're trying to fill array of string with object of array, it's not allowed.