public class ApacheCommonsLangUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY
The empty String
"". |
static int |
INDEX_NOT_FOUND
The index value when an element is not found in a list or array:
-1. |
| Constructor and Description |
|---|
ApacheCommonsLangUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
addAll(T[] array1,
T... array2)
Adds all the elements of the given arrays into a new array.
|
static String |
capitalize(String str)
Capitalizes all the whitespace separated words in a String.
|
static String |
capitalize(String str,
char... delimiters)
Capitalizes all the delimiter separated words in a String.
|
static String |
capitalizeFully(String str)
Converts all the whitespace separated words in a String into capitalized words,
that is each word is made up of a titlecase character and then a series of
lowercase characters.
|
static String |
capitalizeFully(String str,
char... delimiters)
Converts all the delimiter separated words in a String into capitalized words,
that is each word is made up of a titlecase character and then a series of
lowercase characters.
|
static <T> T[] |
clone(T[] array)
Shallow clones an array returning a typecast result and handling
null. |
static int |
indexOf(Object[] array,
Object objectToFind)
Finds the index of the given object in the array.
|
static int |
indexOf(Object[] array,
Object objectToFind,
int startIndex)
Finds the index of the given object in the array starting at the given index.
|
static boolean |
isDelimiter(char ch,
char[] delimiters)
Is the character a delimiter.
|
static boolean |
isNumeric(CharSequence cs)
Checks if the CharSequence contains only Unicode digits.
|
static String |
join(byte[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(byte[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(char[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(char[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(double[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(double[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(float[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(float[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(int[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(int[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(Iterable<?> iterable,
char separator)
Joins the elements of the provided
Iterable into
a single String containing the provided elements. |
static String |
join(Iterable<?> iterable,
String separator)
Joins the elements of the provided
Iterable into
a single String containing the provided elements. |
static String |
join(Iterator<?> iterator,
char separator)
Joins the elements of the provided
Iterator into
a single String containing the provided elements. |
static String |
join(Iterator<?> iterator,
String separator)
Joins the elements of the provided
Iterator into
a single String containing the provided elements. |
static String |
join(long[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(long[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(Object[] array,
char separator)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static String |
join(Object[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static String |
join(Object[] array,
String separator)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static String |
join(Object[] array,
String separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static String |
join(short[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(short[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static <T> String |
join(T... elements)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static boolean |
startsWith(CharSequence str,
CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
|
static boolean |
startsWithIgnoreCase(CharSequence str,
CharSequence prefix)
Case insensitive check if a CharSequence starts with a specified prefix.
|
public static final String EMPTY
"".public static final int INDEX_NOT_FOUND
-1.
This value is returned by methods in this class and can also be used in comparisons with values returned by
various method from List.public ApacheCommonsLangUtil()
public static <T> T[] clone(T[] array)
Shallow clones an array returning a typecast result and handling
null.
The objects in the array are not cloned, thus there is no special handling for multi-dimensional arrays.
This method returns null for a null input array.
T - the component type of the arrayarray - the array to shallow clone, may be nullnull if null inputpublic static <T> T[] addAll(T[] array1, T... array2)
Adds all the elements of the given arrays into a new array.
The new array contains all of the element of array1 followed
by all of the elements array2. When an array is returned, it is always
a new array.
ArrayUtils.addAll(null, null) = null ArrayUtils.addAll(array1, null) = cloned copy of array1 ArrayUtils.addAll(null, array2) = cloned copy of array2 ArrayUtils.addAll([], []) = [] ArrayUtils.addAll([null], [null]) = [null, null] ArrayUtils.addAll(["a", "b", "c"], ["1", "2", "3"]) = ["a", "b", "c", "1", "2", "3"]
T - the component type of the arrayarray1 - the first array whose elements are added to the new array, may be nullarray2 - the second array whose elements are added to the new array, may be nullnull if both arrays are null.
The type of the new array is the type of the first array,
unless the first array is null, in which case the type is the same as the second array.IllegalArgumentException - if the array types are incompatiblepublic static String capitalizeFully(String str)
Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
Whitespace is defined by Character.isWhitespace(char).
A null input String returns null.
Capitalization uses the Unicode title case, normally equivalent to
upper case.
WordUtils.capitalizeFully(null) = null
WordUtils.capitalizeFully("") = ""
WordUtils.capitalizeFully("i am FINE") = "I Am Fine"
str - the String to capitalize, may be nullnull if null String inputpublic static String capitalizeFully(String str, char... delimiters)
Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.
A null input String returns null.
Capitalization uses the Unicode title case, normally equivalent to
upper case.
WordUtils.capitalizeFully(null, *) = null
WordUtils.capitalizeFully("", *) = ""
WordUtils.capitalizeFully(*, null) = *
WordUtils.capitalizeFully(*, new char[0]) = *
WordUtils.capitalizeFully("i aM.fine", {'.'}) = "I am.Fine"
str - the String to capitalize, may be nulldelimiters - set of characters to determine capitalization, null means whitespacenull if null String inputpublic static String capitalize(String str)
Capitalizes all the whitespace separated words in a String.
Only the first character of each word is changed. To convert the
rest of each word to lowercase at the same time,
use capitalizeFully(String).
Whitespace is defined by Character.isWhitespace(char).
A null input String returns null.
Capitalization uses the Unicode title case, normally equivalent to
upper case.
WordUtils.capitalize(null) = null
WordUtils.capitalize("") = ""
WordUtils.capitalize("i am FINE") = "I Am FINE"
str - the String to capitalize, may be nullnull if null String inputcapitalizeFully(String)public static String capitalize(String str, char... delimiters)
Capitalizes all the delimiter separated words in a String.
Only the first character of each word is changed. To convert the
rest of each word to lowercase at the same time,
use capitalizeFully(String, char[]).
The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.
A null input String returns null.
Capitalization uses the Unicode title case, normally equivalent to
upper case.
WordUtils.capitalize(null, *) = null
WordUtils.capitalize("", *) = ""
WordUtils.capitalize(*, new char[0]) = *
WordUtils.capitalize("i am fine", null) = "I Am Fine"
WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine"
str - the String to capitalize, may be nulldelimiters - set of characters to determine capitalization, null means whitespacenull if null String inputcapitalizeFully(String)public static boolean isDelimiter(char ch, char[] delimiters)
ch - the character to checkdelimiters - the delimiters@SafeVarargs public static <T> String join(T... elements)
Joins the elements of the provided array into a single String containing the provided list of elements.
No separator is added to the joined String. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null) = null StringUtils.join([]) = "" StringUtils.join([null]) = "" StringUtils.join(["a", "b", "c"]) = "abc" StringUtils.join([null, "", "a"]) = "a"
T - the specific type of values to join togetherelements - the values to join together, may be nullnull if null array inputpublic static String join(Object[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], ';') = "a;b;c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join([null, "", "a"], ';') = ";;a"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(long[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(int[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(short[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(byte[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(char[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(float[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(double[] array, char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(Object[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], ';') = "a;b;c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join([null, "", "a"], ';') = ";;a"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is
an error to pass in an end index past the end of the arrayendIndex - the index to stop joining from (exclusive). It is
an error to pass in an end index past the end of the arraynull if null array inputpublic static String join(long[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(int[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(byte[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(short[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(char[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(double[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(float[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is an error to pass in an end index past the end of the
arrayendIndex - the index to stop joining from (exclusive). It is an error to pass in an end index past the end of
the arraynull if null array inputpublic static String join(Object[] array, String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list.
A null separator is the same as an empty String ("").
Null objects or empty strings within the array are represented by
empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], "--") = "a--b--c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join(["a", "b", "c"], "") = "abc" StringUtils.join([null, "", "a"], ',') = ",,a"
array - the array of values to join together, may be nullseparator - the separator character to use, null treated as ""null if null array inputpublic static String join(Object[] array, String separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list.
A null separator is the same as an empty String ("").
Null objects or empty strings within the array are represented by
empty strings.
StringUtils.join(null, *, *, *) = null StringUtils.join([], *, *, *) = "" StringUtils.join([null], *, *, *) = "" StringUtils.join(["a", "b", "c"], "--", 0, 3) = "a--b--c" StringUtils.join(["a", "b", "c"], "--", 1, 3) = "b--c" StringUtils.join(["a", "b", "c"], "--", 2, 3) = "c" StringUtils.join(["a", "b", "c"], "--", 2, 2) = "" StringUtils.join(["a", "b", "c"], null, 0, 3) = "abc" StringUtils.join(["a", "b", "c"], "", 0, 3) = "abc" StringUtils.join([null, "", "a"], ',', 0, 3) = ",,a"
array - the array of values to join together, may be nullseparator - the separator character to use, null treated as ""startIndex - the first index to start joining from.endIndex - the index to stop joining from (exclusive).null if null array input; or the empty string
if endIndex - startIndex <= 0. The number of joined entries is given by
endIndex - startIndexArrayIndexOutOfBoundsException - ifestartIndex < 0 or startIndex >= array.length() or endIndex < 0 or endIndex > array.length()public static String join(Iterator<?> iterator, char separator)
Joins the elements of the provided Iterator into
a single String containing the provided elements.
No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here: join(Object[],char).
iterator - the Iterator of values to join together, may be nullseparator - the separator character to usenull if null iterator inputpublic static String join(Iterator<?> iterator, String separator)
Joins the elements of the provided Iterator into
a single String containing the provided elements.
No delimiter is added before or after the list.
A null separator is the same as an empty String ("").
See the examples here: join(Object[],String).
iterator - the Iterator of values to join together, may be nullseparator - the separator character to use, null treated as ""null if null iterator inputpublic static String join(Iterable<?> iterable, char separator)
Joins the elements of the provided Iterable into
a single String containing the provided elements.
No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here: join(Object[],char).
iterable - the Iterable providing the values to join together, may be nullseparator - the separator character to usenull if null iterator inputpublic static String join(Iterable<?> iterable, String separator)
Joins the elements of the provided Iterable into
a single String containing the provided elements.
No delimiter is added before or after the list.
A null separator is the same as an empty String ("").
See the examples here: join(Object[],String).
iterable - the Iterable providing the values to join together, may be nullseparator - the separator character to use, null treated as ""null if null iterator inputpublic static boolean isNumeric(CharSequence cs)
Checks if the CharSequence contains only Unicode digits. A decimal point is not a Unicode digit and returns false.
null will return false.
An empty CharSequence (length()=0) will return false.
Note that the method does not allow for a leading sign, either positive or negative. Also, if a String passes the numeric test, it may still generate a NumberFormatException when parsed by Integer.parseInt or Long.parseLong, e.g. if the value is outside the range for int or long respectively.
StringUtils.isNumeric(null) = false
StringUtils.isNumeric("") = false
StringUtils.isNumeric(" ") = false
StringUtils.isNumeric("123") = true
StringUtils.isNumeric("१२३") = true
StringUtils.isNumeric("12 3") = false
StringUtils.isNumeric("ab2c") = false
StringUtils.isNumeric("12-3") = false
StringUtils.isNumeric("12.3") = false
StringUtils.isNumeric("-123") = false
StringUtils.isNumeric("+123") = false
cs - the CharSequence to check, may be nulltrue if only contains digits, and is non-nullpublic static boolean startsWith(CharSequence str, CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
StringUtils.startsWith(null, null) = true
StringUtils.startsWith(null, "abc") = false
StringUtils.startsWith("abcdef", null) = false
StringUtils.startsWith("abcdef", "abc") = true
StringUtils.startsWith("ABCDEF", "abc") = false
str - the CharSequence to check, may be nullprefix - the prefix to find, may be nulltrue if the CharSequence starts with the prefix, case sensitive, or
both nullString.startsWith(String)public static boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix)
Case insensitive check if a CharSequence starts with a specified prefix.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case insensitive.
StringUtils.startsWithIgnoreCase(null, null) = true
StringUtils.startsWithIgnoreCase(null, "abc") = false
StringUtils.startsWithIgnoreCase("abcdef", null) = false
StringUtils.startsWithIgnoreCase("abcdef", "abc") = true
StringUtils.startsWithIgnoreCase("ABCDEF", "abc") = true
str - the CharSequence to check, may be nullprefix - the prefix to find, may be nulltrue if the CharSequence starts with the prefix, case insensitive, or
both nullString.startsWith(String)public static int indexOf(Object[] array, Object objectToFind)
Finds the index of the given object in the array.
This method returns INDEX_NOT_FOUND (-1) for a null input array.
array - the array to search through for the object, may be nullobjectToFind - the object to find, may be nullINDEX_NOT_FOUND (-1) if not found or null array inputpublic static int indexOf(Object[] array, Object objectToFind, int startIndex)
Finds the index of the given object in the array starting at the given index.
This method returns INDEX_NOT_FOUND (-1) for a null input array.
A negative startIndex is treated as zero. A startIndex larger than the array
length will return INDEX_NOT_FOUND (-1).
array - the array to search through for the object, may be nullobjectToFind - the object to find, may be nullstartIndex - the index to start searching atINDEX_NOT_FOUND (-1) if not found or null array inputCopyright © 2017. All rights reserved.