Class XArray
- Object
-
- 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++'srealloc
.- 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)
Returnstrue
if all values in the specified array are equals to the specified value, which may beDouble.NaN
.static boolean
allEquals(float[] array, float value)
Returnstrue
if all values in the specified array are equals to the specified value, which may beFloat.NaN
.static boolean
contains(Object[] array, Object value)
Returnstrue
if the specified array contains the specified value.static boolean
containsIgnoreCase(String[] array, String value)
Returnstrue
if the specified array contains the specified value, ignoring case.static boolean
hasNaN(double[] array)
Returnstrue
if the specified array contains at least oneNaN
value.static boolean
hasNaN(float[] array)
Returnstrue
if the specified array contains at least oneNaN
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)
Returnstrue
if at least one element in the first array is equals to an element in the second array.static boolean
isSorted(byte[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(char[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(double[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(float[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(int[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(long[] array)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isSorted(short[] array)
Returnstrue
if all elements in the specified array are in increasing order.static <T> boolean
isSorted(T[] array, Comparator<T> comparator)
Returnstrue
if all elements in the specified array are in increasing order.static boolean
isStrictlySorted(int[] array)
Returnstrue
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 givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static byte[]
resize(byte[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static char[]
resize(char[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static double[]
resize(double[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static float[]
resize(float[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static int[]
resize(int[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static long[]
resize(long[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static short[]
resize(short[] array, int length)
Returns an array containing the same elements as the givenarray
but specifiedlength
, truncating or padding with zeros if necessary.static <E> E[]
resize(E[] array, int length)
Returns an array containing the same elements as the givenarray
but with the specifiedlength
, truncating or padding withnull
if necessary.static String
toString(Object array, Locale locale)
Returns a string representation of an array of numbers.
-
-
-
Method Detail
-
resize
public static <E> E[] resize(E[] array, int length)
Returns an array containing the same elements as the givenarray
but with the specifiedlength
, truncating or padding withnull
if necessary.-
If the given
length
is longer than the length of the givenarray
, then the returned array will contain all the elements ofarray
at index i <array.length
. Elements at index i >=array.length
are initialized tonull
. -
If the given
length
is shorter than the length of the givenarray
, then the returned array will contain only the elements ofarray
at index i <length
. Remainding elements are not copied. -
If the given
length
is equals to the length of the givenarray
, thenarray
is returned unchanged. No copy is performed. This behavior is what make this method different thanArrays#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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
but specifiedlength
, 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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 givenarray
.length
- Number of elements to remove.- Returns:
- Array with the same elements than the given
array
except for the removed elements, orarray
iflength
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 tonull
.- Parameters:
array
- Array in which to insert spaces.index
- Index where the first space should be inserted. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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 tofalse
.- Parameters:
array
- Array in which to insert spaces.index
- Index where the first space should be inserted. Allarray
elements having an index equal to or higher thanindex
will be moved forward.length
- Number of spaces to insert.- Returns:
- Array containing the
array
elements with the additional space inserted, orarray
iflength
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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. 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. Thesrc
table will be entirely or partially inserted into thedst
table.- Parameters:
src
- Tablea to insert intodst
.src_pos
- Index of the first data item ofsrc
to insert intodst
.dst
- Table in which to insertsrc
data.dst_pos
-dst
index in which to insertsrc
data. All elements ofdst
whose index is equal to or greater thandst_pos
will be moved forward.length
- Number ofsrc
data items to insert.- Returns:
- Table which contains the combination of
src
anddst
. This method can directly returndst
, but neversrc
. It most often returns a newly created table.
-
isSorted
public static <T> boolean isSorted(T[] array, Comparator<T> comparator)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(char[] array)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(byte[] array)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(short[] array)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(int[] array)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(long[] array)
Returnstrue
if all elements in the specified array are in increasing order. This method is usefull in assertions.
-
isSorted
public static boolean isSorted(float[] array)
Returnstrue
if all elements in the specified array are in increasing order. SinceNaN
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)
Returnstrue
if all elements in the specified array are in increasing order. SinceNaN
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)
Returnstrue
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)
Returnstrue
if all values in the specified array are equals to the specified value, which may beFloat.NaN
.
-
allEquals
public static boolean allEquals(double[] array, double value)
Returnstrue
if all values in the specified array are equals to the specified value, which may beDouble.NaN
.
-
hasNaN
public static boolean hasNaN(float[] array)
Returnstrue
if the specified array contains at least oneNaN
value.
-
hasNaN
public static boolean hasNaN(double[] array)
Returnstrue
if the specified array contains at least oneNaN
value.
-
containsIgnoreCase
public static boolean containsIgnoreCase(String[] array, String value)
Returnstrue
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 benull
.value
- The value to search.- Returns:
true
if the array contains the value.
-
contains
public static boolean contains(Object[] array, Object value)
Returnstrue
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 usingHashSet
instead.- Parameters:
array
- The array to search in. May benull
and may contains null elements.value
- The value to search. May benull
.- Returns:
true
if the array contains the value.
-
intersects
public static boolean intersects(Object[] array1, Object[] array2)
Returnstrue
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 ofNumber
.- Parameters:
array
- The array to format.locale
- The locale for formatting.- Returns:
- The formatted array.
-
-