Class ArrayJoiner

java.lang.Object
org.flag4j.util.ArrayJoiner

public final class ArrayJoiner extends Object
The ArrayJoiner class provides utility methods for combining and repeating arrays. It simplifies operations involving concatenating and repeating arrays.

Example Usage:


 // Join two arrays
 int[] array1 = {1, 2, 3};
 int[] array2 = {4, 5, 6};
 int[] joinedArray = ArrayJoiner.join(array1, array2); // {1, 2, 3, 4, 5, 6}

 // Repeat an array
 int[] repeatedArray = ArrayJoiner.repeat(3, array1); // {1, 2, 3, 1, 2, 3, 1, 2, 3}
 

Note: This class is a utility class and cannot be instantiated.

  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    join(double[] src1, double[] src2)
    Joins two arrays together.
    static int[]
    join(int[] src1, int[] src2)
    Joins two arrays together.
    static int[]
    repeat(int numTimes, int[] src)
    Repeats an array a specified number of times.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • join

      public static double[] join(double[] src1, double[] src2)
      Joins two arrays together.
      Parameters:
      src1 - First array to join.
      src2 - Second array to join.
      Returns:
      A single array of length src1.length + src2.length containing the elements of src1 followed by the elements of src2.
    • join

      public static int[] join(int[] src1, int[] src2)
      Joins two arrays together.
      Parameters:
      src1 - First array to join.
      src2 - Second array to join.
      Returns:
      A single array of length src1.length + src2.length containing the elements of src1 followed by the elements of src2.
    • repeat

      public static int[] repeat(int numTimes, int[] src)
      Repeats an array a specified number of times.
      Parameters:
      numTimes - Number of times to repeat the array.
      src - The source array to repeat.
      Returns:
      The src array repeated numTimes times.