Class ArrayHelper

java.lang.Object
com.Ostermiller.util.ArrayHelper

public final class ArrayHelper extends Object
Convenience methods for working with Java arrays. More information about this class is available from ostermiller.org.
Since:
ostermillerutils 1.06.00
Author:
Stephen Ostermiller https://ostermiller.org/contact.pl?regarding=Java+Utilities
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object[]
    cat(Object[] arr1, Object[] arr2)
    Concatenates the given arrays into a single long array.
    static boolean
    equal(Object[] arr1, Object[] arr2)
    Tests two arrays to see if the arrays are equal.
    static void
    print(Object[] arr)
    Prints out a comma separated list of all the objects in the array on a single line in CSV format.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArrayHelper

      public ArrayHelper()
  • Method Details

    • cat

      public static Object[] cat(Object[] arr1, Object[] arr2)
      Concatenates the given arrays into a single long array. The returned array will be of the common super type of the two given arrays.

      For example it can be called like this:

       String[] arr = (String[])ArrayHelper.cat(new String[]{"one","two"}, new String[]{"three","four"});
       
      Parameters:
      arr1 - first array
      arr2 - second array
      Returns:
      an array whose length is the sum of the given array's lengths and contains all the elements in the given arrays.
      Since:
      ostermillerutils 1.06.00
    • print

      public static void print(Object[] arr)
      Prints out a comma separated list of all the objects in the array on a single line in CSV format.
      Parameters:
      arr - Array to print in comma separated value format
      Since:
      ostermillerutils 1.06.00
    • equal

      public static boolean equal(Object[] arr1, Object[] arr2)
      Tests two arrays to see if the arrays are equal. Two arrays will be equal only if they are the same length and contain objects that are equal in the same order.
      Parameters:
      arr1 - first array
      arr2 - second array
      Returns:
      true iff two arguments are equal
      Since:
      ostermillerutils 1.06.00