Java Utililty Methods Array Fill

List of utility methods to do Array Fill

Description

The list of methods to do Array Fill are organized into topic(s).

Method

String[]fillArray(String[] array, int size, String fillString)
fill Array
if (array == null) {
    return null;
String[] fillArray = new String[size];
for (int index = 0; index < fillArray.length; index++) {
    String fillValue = fillString;
    if (index < array.length) {
        fillValue = array[index];
...
voidfillArray(T[] arr, T val)
Fill given array with given repeated value
if (arr != null)
    for (int i = 0; i < arr.length; i++)
        arr[i] = val;
voidfillArray2D(double[][] arr, double value)
fill Array D
for (int i = 0; i < arr.length; i++) {
    double[] col = arr[i];
    Arrays.fill(col, value);
voidfillArrayWith(byte[] dest, byte[] pattern)
fill Array With
int count = 0;
while (count < dest.length) {
    for (int i = 0; i < pattern.length; i++) {
        dest[count] = pattern[i];
        count++;
voidfillArrayWithByte(byte[] array, byte value)
fill Array With Byte
for (int i = 0; i < array.length; i++)
    array[i] = value;
voidfillArrayWithHalfSorted(int[] nums)
fill Array With Half Sorted
for (int i = 0; i < nums.length / 2; i++)
    nums[i] = i;
int start = nums.length;
for (int i = nums.length / 2; i < nums.length; i++)
    nums[i] = start--;
voidfillColor(int[][] dist)
fill Color
int white = 0xff << 24;
for (int i = 0; i < dist.length; i++) {
    Arrays.fill(dist[i], white);
int[]filledIntArray(int length, int cont)
filled Int Array
int[] res = new int[length];
Arrays.fill(res, cont);
return res;