Class XArray


  • public final class XArray
    extends Object
    Simple operations on arrays. This class provides a central place for inserting and deleting elements in an array, as well as resizing the array. This class may be removed if JavaSoft provide some language construct functionally equivalent to C/C++'s realloc.
    Since:
    2.0
    Author:
    Martin Desruisseaux (IRD)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean allEquals​(double[] array, double value)
      Returns true if all values in the specified array are equals to the specified value, which may be Double.NaN.
      static boolean allEquals​(float[] array, float value)
      Returns true if all values in the specified array are equals to the specified value, which may be Float.NaN.
      static boolean contains​(Object[] array, Object value)
      Returns true if the specified array contains the specified value.
      static boolean containsIgnoreCase​(String[] array, String value)
      Returns true if the specified array contains the specified value, ignoring case.
      static boolean hasNaN​(double[] array)
      Returns true if the specified array contains at least one NaN value.
      static boolean hasNaN​(float[] array)
      Returns true if the specified array contains at least one NaN value.
      static boolean[] insert​(boolean[] src, int src_pos, boolean[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static boolean[] insert​(boolean[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static byte[] insert​(byte[] src, int src_pos, byte[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static byte[] insert​(byte[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static char[] insert​(char[] src, int src_pos, char[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static char[] insert​(char[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static double[] insert​(double[] src, int src_pos, double[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static double[] insert​(double[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static float[] insert​(float[] src, int src_pos, float[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static float[] insert​(float[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static int[] insert​(int[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static int[] insert​(int[] src, int src_pos, int[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static long[] insert​(long[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static long[] insert​(long[] src, int src_pos, long[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static short[] insert​(short[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static short[] insert​(short[] src, int src_pos, short[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static <E> E[] insert​(E[] array, int index, int length)
      Inserts spaces into the middle of an array.
      static <E> E[] insert​(E[] src, int src_pos, E[] dst, int dst_pos, int length)
      Inserts a table slice into another table.
      static boolean intersects​(Object[] array1, Object[] array2)
      Returns true if at least one element in the first array is equals to an element in the second array.
      static boolean isSorted​(byte[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(char[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(double[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(float[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(int[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(long[] array)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isSorted​(short[] array)
      Returns true if all elements in the specified array are in increasing order.
      static <T> boolean isSorted​(T[] array, Comparator<T> comparator)
      Returns true if all elements in the specified array are in increasing order.
      static boolean isStrictlySorted​(int[] array)
      Returns true if all elements in the specified array are in strictly increasing order.
      static boolean[] remove​(boolean[] array, int index, int length)
      Removes elements from the middle of an array.
      static byte[] remove​(byte[] array, int index, int length)
      Removes elements from the middle of an array.
      static char[] remove​(char[] array, int index, int length)
      Removes elements from the middle of an array.
      static double[] remove​(double[] array, int index, int length)
      Removes elements from the middle of an array.
      static float[] remove​(float[] array, int index, int length)
      Removes elements from the middle of an array.
      static int[] remove​(int[] array, int index, int length)
      Removes elements from the middle of an array.
      static long[] remove​(long[] array, int index, int length)
      Removes elements from the middle of an array.
      static short[] remove​(short[] array, int index, int length)
      Removes elements from the middle of an array.
      static <E> E[] remove​(E[] array, int index, int length)
      Removes elements from the middle of an array.
      static boolean[] resize​(boolean[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static byte[] resize​(byte[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static char[] resize​(char[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static double[] resize​(double[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static float[] resize​(float[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static int[] resize​(int[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static long[] resize​(long[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static short[] resize​(short[] array, int length)
      Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
      static <E> E[] resize​(E[] array, int length)
      Returns an array containing the same elements as the given array but with the specified length, truncating or padding with null if necessary.
      static String toString​(Object array, Locale locale)
      Returns a string representation of an array of numbers.
      • Methods inherited from class Object

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

      • resize

        public static <E> E[] resize​(E[] array,
                                     int length)
        Returns an array containing the same elements as the given array but with the specified length, truncating or padding with null if necessary.
        • If the given length is longer than the length of the given array, then the returned array will contain all the elements of array at index i < array.length. Elements at index i >= array.length are initialized to null.

        • If the given length is shorter than the length of the given array, then the returned array will contain only the elements of array at index i < length. Remainding elements are not copied.

        • If the given length is equals to the length of the given array, then array is returned unchanged. No copy is performed. This behavior is what make this method different than Arrays#copyOf.

        Type Parameters:
        E - The array elements.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
        See Also:
        Arrays#copyOf(Object[],int)
      • resize

        public static double[] resize​(double[] array,
                                      int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static float[] resize​(float[] array,
                                     int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static long[] resize​(long[] array,
                                    int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static int[] resize​(int[] array,
                                   int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static short[] resize​(short[] array,
                                     int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static byte[] resize​(byte[] array,
                                    int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static char[] resize​(char[] array,
                                    int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • resize

        public static boolean[] resize​(boolean[] array,
                                       int length)
        Returns an array containing the same elements as the given array but specified length, truncating or padding with zeros if necessary.
        Parameters:
        array - Array to copy.
        length - Length of the desired array.
        Returns:
        A new array of the requested length, or array if the original array already have the requested length.
      • remove

        public static <E> E[] remove​(E[] array,
                                     int index,
                                     int length)
        Removes elements from the middle of an array.
        Type Parameters:
        E - The type of array elements.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static double[] remove​(double[] array,
                                      int index,
                                      int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static float[] remove​(float[] array,
                                     int index,
                                     int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static long[] remove​(long[] array,
                                    int index,
                                    int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static int[] remove​(int[] array,
                                   int index,
                                   int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static short[] remove​(short[] array,
                                     int index,
                                     int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static byte[] remove​(byte[] array,
                                    int index,
                                    int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static char[] remove​(char[] array,
                                    int index,
                                    int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • remove

        public static boolean[] remove​(boolean[] array,
                                       int index,
                                       int length)
        Removes elements from the middle of an array.
        Parameters:
        array - Array from which to remove elements.
        index - Index of the first element to remove from the given array.
        length - Number of elements to remove.
        Returns:
        Array with the same elements than the given array except for the removed elements, or array if length is 0.
      • insert

        public static <E> E[] insert​(E[] array,
                                     int index,
                                     int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to null.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static double[] insert​(double[] array,
                                      int index,
                                      int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static float[] insert​(float[] array,
                                     int index,
                                     int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static long[] insert​(long[] array,
                                    int index,
                                    int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static int[] insert​(int[] array,
                                   int index,
                                   int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static short[] insert​(short[] array,
                                     int index,
                                     int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static byte[] insert​(byte[] array,
                                    int index,
                                    int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static char[] insert​(char[] array,
                                    int index,
                                    int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to zeros.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static boolean[] insert​(boolean[] array,
                                       int index,
                                       int length)
        Inserts spaces into the middle of an array. These "spaces" will be made up of elements initialized to false.
        Parameters:
        array - Array in which to insert spaces.
        index - Index where the first space should be inserted. All array elements having an index equal to or higher than index will be moved forward.
        length - Number of spaces to insert.
        Returns:
        Array containing the array elements with the additional space inserted, or array if length is 0.
      • insert

        public static <E> E[] insert​(E[] src,
                                     int src_pos,
                                     E[] dst,
                                     int dst_pos,
                                     int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static double[] insert​(double[] src,
                                      int src_pos,
                                      double[] dst,
                                      int dst_pos,
                                      int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static float[] insert​(float[] src,
                                     int src_pos,
                                     float[] dst,
                                     int dst_pos,
                                     int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static long[] insert​(long[] src,
                                    int src_pos,
                                    long[] dst,
                                    int dst_pos,
                                    int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static int[] insert​(int[] src,
                                   int src_pos,
                                   int[] dst,
                                   int dst_pos,
                                   int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static short[] insert​(short[] src,
                                     int src_pos,
                                     short[] dst,
                                     int dst_pos,
                                     int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static byte[] insert​(byte[] src,
                                    int src_pos,
                                    byte[] dst,
                                    int dst_pos,
                                    int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static char[] insert​(char[] src,
                                    int src_pos,
                                    char[] dst,
                                    int dst_pos,
                                    int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • insert

        public static boolean[] insert​(boolean[] src,
                                       int src_pos,
                                       boolean[] dst,
                                       int dst_pos,
                                       int length)
        Inserts a table slice into another table. The src table will be entirely or partially inserted into the dst table.
        Parameters:
        src - Tablea to insert into dst.
        src_pos - Index of the first data item of src to insert into dst.
        dst - Table in which to insert src data.
        dst_pos - dst index in which to insert src data. All elements of dst whose index is equal to or greater than dst_pos will be moved forward.
        length - Number of src data items to insert.
        Returns:
        Table which contains the combination of src and dst. This method can directly return dst, but never src. It most often returns a newly created table.
      • isSorted

        public static <T> boolean isSorted​(T[] array,
                                           Comparator<T> comparator)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(char[] array)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(byte[] array)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(short[] array)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(int[] array)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(long[] array)
        Returns true if all elements in the specified array are in increasing order. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(float[] array)
        Returns true if all elements in the specified array are in increasing order. Since NaN values are unordered, they may appears anywhere in the array; they will be ignored. This method is usefull in assertions.
      • isSorted

        public static boolean isSorted​(double[] array)
        Returns true if all elements in the specified array are in increasing order. Since NaN values are unordered, they may appears anywhere in the array; they will be ignored. This method is usefull in assertions.
      • isStrictlySorted

        public static boolean isStrictlySorted​(int[] array)
        Returns true if all elements in the specified array are in strictly increasing order. This method is usefull in assertions.
      • allEquals

        public static boolean allEquals​(float[] array,
                                        float value)
        Returns true if all values in the specified array are equals to the specified value, which may be Float.NaN.
      • allEquals

        public static boolean allEquals​(double[] array,
                                        double value)
        Returns true if all values in the specified array are equals to the specified value, which may be Double.NaN.
      • hasNaN

        public static boolean hasNaN​(float[] array)
        Returns true if the specified array contains at least one NaN value.
      • hasNaN

        public static boolean hasNaN​(double[] array)
        Returns true if the specified array contains at least one NaN value.
      • containsIgnoreCase

        public static boolean containsIgnoreCase​(String[] array,
                                                 String value)
        Returns true if the specified array contains the specified value, ignoring case. This method should be used only for very small arrays.
        Parameters:
        array - The array to search in. May be null.
        value - The value to search.
        Returns:
        true if the array contains the value.
      • contains

        public static boolean contains​(Object[] array,
                                       Object value)
        Returns true if the specified array contains the specified value. This method should be used only for very small arrays, or for search to be performed only once, because it performs a linear search. If more than one search need to be done on the same array, consider using HashSet instead.
        Parameters:
        array - The array to search in. May be null and may contains null elements.
        value - The value to search. May be null.
        Returns:
        true if the array contains the value.
      • intersects

        public static boolean intersects​(Object[] array1,
                                         Object[] array2)
        Returns true if at least one element in the first array is equals to an element in the second array. The element doesn't need to be at the same index in both array.

        This method should be used only for very small arrays since it may be very slow. If the arrays are large or if an array will be involved in more than one search, consider using HashSet instead.

      • toString

        public static String toString​(Object array,
                                      Locale locale)
        Returns a string representation of an array of numbers. Current implementation supports only primitive or subclasses of Number.
        Parameters:
        array - The array to format.
        locale - The locale for formatting.
        Returns:
        The formatted array.