{
"RECORDS": [
{
"_id": "6367676d1a6d9265ec018229",
"all_context": "{ \"class_level\" : \"import java.nio.charset.Charset;\\nimport java.util.ArrayList;\\nimport java.util.Arrays;\\nimport java.util.Collection;\\nimport java.util.Enumeration;\\nimport java.util.Iterator;\\nimport java.util.LinkedList;\\nimport java.util.List;\\nimport java.util.Locale;\\nimport java.util.Properties;\\nimport java.util.Set;\\nimport java.util.StringTokenizer;\\nimport java.util.TreeSet;\\nString FOLDER_SEPARATOR;\\nString WINDOWS_FOLDER_SEPARATOR;\\nString TOP_PATH;\\nString CURRENT_PATH;\\nchar EXTENSION_SEPARATOR;\\nCharset UTF_8;\\nStrings();\\nhasLength(String str);\\nhasText(CharSequence str);\\nhasText(String str);\\ncontainsWhitespace(CharSequence str);\\ncontainsWhitespace(String str);\\ntrimWhitespace(String str);\\ntrimWhitespace(CharSequence str);\\nclean(String str);\\nclean(CharSequence str);\\ntrimAllWhitespace(String str);\\ntrimLeadingWhitespace(String str);\\ntrimTrailingWhitespace(String str);\\ntrimLeadingCharacter(String str,char leadingCharacter);\\ntrimTrailingCharacter(String str,char trailingCharacter);\\nstartsWithIgnoreCase(String str,String prefix);\\nendsWithIgnoreCase(String str,String suffix);\\nsubstringMatch(CharSequence str,int index,CharSequence substring);\\ncountOccurrencesOf(String str,String sub);\\nreplace(String inString,String oldPattern,String newPattern);\\ndelete(String inString,String pattern);\\ndeleteAny(String inString,String charsToDelete);\\nquote(String str);\\nquoteIfString(Object obj);\\nunqualify(String qualifiedName);\\nunqualify(String qualifiedName,char separator);\\ncapitalize(String str);\\nuncapitalize(String str);\\nchangeFirstCharacterCase(String str,boolean capitalize);\\ngetFilename(String path);\\ngetFilenameExtension(String path);\\nstripFilenameExtension(String path);\\napplyRelativePath(String path,String relativePath);\\ncleanPath(String path);\\npathEquals(String path1,String path2);\\nparseLocaleString(String localeString);\\nvalidateLocalePart(String localePart);\\ntoLanguageTag(Locale locale);\\naddStringToArray(String[] array,String str);\\nconcatenateStringArrays(String[] array1,String[] array2);\\nmergeStringArrays(String[] array1,String[] array2);\\nsortStringArray(String[] array);\\ntoStringArray(Collection collection);\\ntoStringArray(Enumeration enumeration);\\ntrimArrayElements(String[] array);\\nremoveDuplicateStrings(String[] array);\\nsplit(String toSplit,String delimiter);\\nsplitArrayElementsIntoProperties(String[] array,String delimiter);\\nsplitArrayElementsIntoProperties(String[] array,String delimiter,String charsToDelete);\\ntokenizeToStringArray(String str,String delimiters);\\ntokenizeToStringArray(String str,String delimiters,boolean trimTokens,boolean ignoreEmptyTokens);\\ndelimitedListToStringArray(String str,String delimiter);\\ndelimitedListToStringArray(String str,String delimiter,String charsToDelete);\\ncommaDelimitedListToStringArray(String str);\\ncommaDelimitedListToSet(String str);\\ncollectionToDelimitedString(Collection coll,String delim,String prefix,String suffix);\\ncollectionToDelimitedString(Collection coll,String delim);\\ncollectionToCommaDelimitedString(Collection coll);\\narrayToDelimitedString(Object[] arr,String delim);\\narrayToCommaDelimitedString(Object[] arr);\\nhasLength(CharSequence str);\\n\", \"repo_level\" : \"\" }",
"class_name": "Strings",
"code": "public static String[] trimArrayElements(String[] array){\n if (Objects.isEmpty(array)) {\n return new String[0];\n }\n String[] result=new String[array.length];\n for (int i=0; i < array.length; i++) {\n String element=array[i];\n result[i]=(element != null ? element.trim() : null);\n }\n return result;\n}\n",
"docstring": "/** \n * Trim the elements of the given String array, calling String.trim() on each of them.\n * @param array the original String array\n * @return the resulting array (of the same size) with trimmed elements\n */\n",
"end_lineno": "842",
"file_content": "/*\n * Copyright (C) 2014 jsonwebtoken.io\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.jsonwebtoken.lang;\n\nimport java.nio.charset.Charset;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Enumeration;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Locale;\nimport java.util.Properties;\nimport java.util.Set;\nimport java.util.StringTokenizer;\nimport java.util.TreeSet;\n\npublic final class Strings {\n\n private static final String FOLDER_SEPARATOR = \"/\";\n\n private static final String WINDOWS_FOLDER_SEPARATOR = \"\\\\\";\n\n private static final String TOP_PATH = \"..\";\n\n private static final String CURRENT_PATH = \".\";\n\n private static final char EXTENSION_SEPARATOR = '.';\n\n public static final Charset UTF_8 = Charset.forName(\"UTF-8\");\n\n private Strings(){} //prevent instantiation\n\n //---------------------------------------------------------------------\n // General convenience methods for working with Strings\n //---------------------------------------------------------------------\n\n /**\n * Check that the given CharSequence is neither null nor of length 0.\n * Note: Will return true for a CharSequence that purely consists of whitespace.\n *
\n * Strings.hasLength(null) = false\n * Strings.hasLength(\"\") = false\n * Strings.hasLength(\" \") = true\n * Strings.hasLength(\"Hello\") = true\n *\n * @param str the CharSequence to check (may be
null)\n * @return true if the CharSequence is not null and has length\n * @see #hasText(String)\n */\n public static boolean hasLength(CharSequence str) {\n return (str != null && str.length() > 0);\n }\n\n /**\n * Check that the given String is neither null nor of length 0.\n * Note: Will return true for a String that purely consists of whitespace.\n * @param str the String to check (may be null)\n * @return true if the String is not null and has length\n * @see #hasLength(CharSequence)\n */\n public static boolean hasLength(String str) {\n return hasLength((CharSequence) str);\n }\n\n /**\n * Check whether the given CharSequence has actual text.\n * More specifically, returns true if the string not null,\n * its length is greater than 0, and it contains at least one non-whitespace character.\n * \n * Strings.hasText(null) = false\n * Strings.hasText(\"\") = false\n * Strings.hasText(\" \") = false\n * Strings.hasText(\"12345\") = true\n * Strings.hasText(\" 12345 \") = true\n *\n * @param str the CharSequence to check (may be
null)\n * @return true if the CharSequence is not null,\n * its length is greater than 0, and it does not contain whitespace only\n * @see java.lang.Character#isWhitespace\n */\n public static boolean hasText(CharSequence str) {\n if (!hasLength(str)) {\n return false;\n }\n int strLen = str.length();\n for (int i = 0; i < strLen; i++) {\n if (!Character.isWhitespace(str.charAt(i))) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check whether the given String has actual text.\n * More specifically, returns true if the string not null,\n * its length is greater than 0, and it contains at least one non-whitespace character.\n * @param str the String to check (may be null)\n * @return true if the String is not null, its length is\n * greater than 0, and it does not contain whitespace only\n * @see #hasText(CharSequence)\n */\n public static boolean hasText(String str) {\n return hasText((CharSequence) str);\n }\n\n /**\n * Check whether the given CharSequence contains any whitespace characters.\n * @param str the CharSequence to check (may be null)\n * @return true if the CharSequence is not empty and\n * contains at least 1 whitespace character\n * @see java.lang.Character#isWhitespace\n */\n public static boolean containsWhitespace(CharSequence str) {\n if (!hasLength(str)) {\n return false;\n }\n int strLen = str.length();\n for (int i = 0; i < strLen; i++) {\n if (Character.isWhitespace(str.charAt(i))) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check whether the given String contains any whitespace characters.\n * @param str the String to check (may be null)\n * @return true if the String is not empty and\n * contains at least 1 whitespace character\n * @see #containsWhitespace(CharSequence)\n */\n public static boolean containsWhitespace(String str) {\n return containsWhitespace((CharSequence) str);\n }\n\n /**\n * Trim leading and trailing whitespace from the given String.\n * @param str the String to check\n * @return the trimmed String\n * @see java.lang.Character#isWhitespace\n */\n public static String trimWhitespace(String str) {\n return (String) trimWhitespace((CharSequence)str);\n }\n \n \n private static CharSequence trimWhitespace(CharSequence str) {\n if (!hasLength(str)) {\n return str;\n }\n final int length = str.length();\n\n int start = 0;\n\t\twhile (start < length && Character.isWhitespace(str.charAt(start))) {\n start++;\n }\n \n\t\tint end = length;\n while (start < length && Character.isWhitespace(str.charAt(end - 1))) {\n end--;\n }\n \n return ((start > 0) || (end < length)) ? str.subSequence(start, end) : str;\n }\n\n public static String clean(String str) {\n \tCharSequence result = clean((CharSequence) str);\n \n return result!=null?result.toString():null;\n }\n \n public static CharSequence clean(CharSequence str) {\n str = trimWhitespace(str);\n if (!hasLength(str)) {\n return null;\n }\n return str;\n }\n\n /**\n * Trim all whitespace from the given String:\n * leading, trailing, and intermediate characters.\n * @param str the String to check\n * @return the trimmed String\n * @see java.lang.Character#isWhitespace\n */\n public static String trimAllWhitespace(String str) {\n if (!hasLength(str)) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str);\n int index = 0;\n while (sb.length() > index) {\n if (Character.isWhitespace(sb.charAt(index))) {\n sb.deleteCharAt(index);\n }\n else {\n index++;\n }\n }\n return sb.toString();\n }\n\n /**\n * Trim leading whitespace from the given String.\n * @param str the String to check\n * @return the trimmed String\n * @see java.lang.Character#isWhitespace\n */\n public static String trimLeadingWhitespace(String str) {\n if (!hasLength(str)) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str);\n while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {\n sb.deleteCharAt(0);\n }\n return sb.toString();\n }\n\n /**\n * Trim trailing whitespace from the given String.\n * @param str the String to check\n * @return the trimmed String\n * @see java.lang.Character#isWhitespace\n */\n public static String trimTrailingWhitespace(String str) {\n if (!hasLength(str)) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str);\n while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) {\n sb.deleteCharAt(sb.length() - 1);\n }\n return sb.toString();\n }\n\n /**\n * Trim all occurrences of the supplied leading character from the given String.\n * @param str the String to check\n * @param leadingCharacter the leading character to be trimmed\n * @return the trimmed String\n */\n public static String trimLeadingCharacter(String str, char leadingCharacter) {\n if (!hasLength(str)) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str);\n while (sb.length() > 0 && sb.charAt(0) == leadingCharacter) {\n sb.deleteCharAt(0);\n }\n return sb.toString();\n }\n\n /**\n * Trim all occurrences of the supplied trailing character from the given String.\n * @param str the String to check\n * @param trailingCharacter the trailing character to be trimmed\n * @return the trimmed String\n */\n public static String trimTrailingCharacter(String str, char trailingCharacter) {\n if (!hasLength(str)) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str);\n while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) {\n sb.deleteCharAt(sb.length() - 1);\n }\n return sb.toString();\n }\n\n\n /**\n * Returns {@code true} if the given string starts with the specified case-insensitive prefix, {@code false} otherwise.\n * @param str the String to check\n * @param prefix the prefix to look for\n * @return {@code true} if the given string starts with the specified case-insensitive prefix, {@code false} otherwise.\n * @see java.lang.String#startsWith\n */\n public static boolean startsWithIgnoreCase(String str, String prefix) {\n if (str == null || prefix == null) {\n return false;\n }\n if (str.startsWith(prefix)) {\n return true;\n }\n if (str.length() < prefix.length()) {\n return false;\n }\n String lcStr = str.substring(0, prefix.length()).toLowerCase();\n String lcPrefix = prefix.toLowerCase();\n return lcStr.equals(lcPrefix);\n }\n\n /**\n * Returns {@code true} if the given string ends with the specified case-insensitive suffix, {@code false} otherwise.\n * @param str the String to check\n * @param suffix the suffix to look for\n * @return {@code true} if the given string ends with the specified case-insensitive suffix, {@code false} otherwise.\n * @see java.lang.String#endsWith\n */\n public static boolean endsWithIgnoreCase(String str, String suffix) {\n if (str == null || suffix == null) {\n return false;\n }\n if (str.endsWith(suffix)) {\n return true;\n }\n if (str.length() < suffix.length()) {\n return false;\n }\n\n String lcStr = str.substring(str.length() - suffix.length()).toLowerCase();\n String lcSuffix = suffix.toLowerCase();\n return lcStr.equals(lcSuffix);\n }\n\n /**\n * Returns {@code true} if the given string matches the given substring at the given index, {@code false} otherwise.\n * @param str the original string (or StringBuilder)\n * @param index the index in the original string to start matching against\n * @param substring the substring to match at the given index\n * @return {@code true} if the given string matches the given substring at the given index, {@code false} otherwise.\n */\n public static boolean substringMatch(CharSequence str, int index, CharSequence substring) {\n for (int j = 0; j < substring.length(); j++) {\n int i = index + j;\n if (i >= str.length() || str.charAt(i) != substring.charAt(j)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Returns the number of occurrences the substring {@code sub} appears in string {@code str}.\n * @param str string to search in. Return 0 if this is null.\n * @param sub string to search for. Return 0 if this is null.\n * @return the number of occurrences the substring {@code sub} appears in string {@code str}.\n */\n public static int countOccurrencesOf(String str, String sub) {\n if (str == null || sub == null || str.length() == 0 || sub.length() == 0) {\n return 0;\n }\n int count = 0;\n int pos = 0;\n int idx;\n while ((idx = str.indexOf(sub, pos)) != -1) {\n ++count;\n pos = idx + sub.length();\n }\n return count;\n }\n\n /**\n * Replace all occurrences of a substring within a string with\n * another string.\n * @param inString String to examine\n * @param oldPattern String to replace\n * @param newPattern String to insert\n * @return a String with the replacements\n */\n public static String replace(String inString, String oldPattern, String newPattern) {\n if (!hasLength(inString) || !hasLength(oldPattern) || newPattern == null) {\n return inString;\n }\n StringBuilder sb = new StringBuilder();\n int pos = 0; // our position in the old string\n int index = inString.indexOf(oldPattern);\n // the index of an occurrence we've found, or -1\n int patLen = oldPattern.length();\n while (index >= 0) {\n sb.append(inString.substring(pos, index));\n sb.append(newPattern);\n pos = index + patLen;\n index = inString.indexOf(oldPattern, pos);\n }\n sb.append(inString.substring(pos));\n // remember to append any characters to the right of a match\n return sb.toString();\n }\n\n /**\n * Delete all occurrences of the given substring.\n * @param inString the original String\n * @param pattern the pattern to delete all occurrences of\n * @return the resulting String\n */\n public static String delete(String inString, String pattern) {\n return replace(inString, pattern, \"\");\n }\n\n /**\n * Delete any character in a given String.\n * @param inString the original String\n * @param charsToDelete a set of characters to delete.\n * E.g. \"az\\n\" will delete 'a's, 'z's and new lines.\n * @return the resulting String\n */\n public static String deleteAny(String inString, String charsToDelete) {\n if (!hasLength(inString) || !hasLength(charsToDelete)) {\n return inString;\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < inString.length(); i++) {\n char c = inString.charAt(i);\n if (charsToDelete.indexOf(c) == -1) {\n sb.append(c);\n }\n }\n return sb.toString();\n }\n\n\n //---------------------------------------------------------------------\n // Convenience methods for working with formatted Strings\n //---------------------------------------------------------------------\n\n /**\n * Quote the given String with single quotes.\n * @param str the input String (e.g. \"myString\")\n * @return the quoted String (e.g. \"'myString'\"),\n * or null if the input was null\n */\n public static String quote(String str) {\n return (str != null ? \"'\" + str + \"'\" : null);\n }\n\n /**\n * Turn the given Object into a String with single quotes\n * if it is a String; keeping the Object as-is else.\n * @param obj the input Object (e.g. \"myString\")\n * @return the quoted String (e.g. \"'myString'\"),\n * or the input object as-is if not a String\n */\n public static Object quoteIfString(Object obj) {\n return (obj instanceof String ? quote((String) obj) : obj);\n }\n\n /**\n * Unqualify a string qualified by a '.' dot character. For example,\n * \"this.name.is.qualified\", returns \"qualified\".\n * @param qualifiedName the qualified name\n * @return an unqualified string by stripping all previous text before (and including) the last period character.\n */\n public static String unqualify(String qualifiedName) {\n return unqualify(qualifiedName, '.');\n }\n\n /**\n * Unqualify a string qualified by a separator character. For example,\n * \"this:name:is:qualified\" returns \"qualified\" if using a ':' separator.\n * @param qualifiedName the qualified name\n * @param separator the separator\n * @return an unqualified string by stripping all previous text before and including the last {@code separator} character.\n */\n public static String unqualify(String qualifiedName, char separator) {\n return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1);\n }\n\n /**\n * Capitalize a String, changing the first letter to\n * upper case as per {@link Character#toUpperCase(char)}.\n * No other letters are changed.\n * @param str the String to capitalize, may be null\n * @return the capitalized String, null if null\n */\n public static String capitalize(String str) {\n return changeFirstCharacterCase(str, true);\n }\n\n /**\n * Uncapitalize a String, changing the first letter to\n * lower case as per {@link Character#toLowerCase(char)}.\n * No other letters are changed.\n * @param str the String to uncapitalize, may be null\n * @return the uncapitalized String, null if null\n */\n public static String uncapitalize(String str) {\n return changeFirstCharacterCase(str, false);\n }\n\n private static String changeFirstCharacterCase(String str, boolean capitalize) {\n if (str == null || str.length() == 0) {\n return str;\n }\n StringBuilder sb = new StringBuilder(str.length());\n if (capitalize) {\n sb.append(Character.toUpperCase(str.charAt(0)));\n }\n else {\n sb.append(Character.toLowerCase(str.charAt(0)));\n }\n sb.append(str.substring(1));\n return sb.toString();\n }\n\n /**\n * Extract the filename from the given path,\n * e.g. \"mypath/myfile.txt\" -> \"myfile.txt\".\n * @param path the file path (may be null)\n * @return the extracted filename, or null if none\n */\n public static String getFilename(String path) {\n if (path == null) {\n return null;\n }\n int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);\n return (separatorIndex != -1 ? path.substring(separatorIndex + 1) : path);\n }\n\n /**\n * Extract the filename extension from the given path,\n * e.g. \"mypath/myfile.txt\" -> \"txt\".\n * @param path the file path (may be null)\n * @return the extracted filename extension, or null if none\n */\n public static String getFilenameExtension(String path) {\n if (path == null) {\n return null;\n }\n int extIndex = path.lastIndexOf(EXTENSION_SEPARATOR);\n if (extIndex == -1) {\n return null;\n }\n int folderIndex = path.lastIndexOf(FOLDER_SEPARATOR);\n if (folderIndex > extIndex) {\n return null;\n }\n return path.substring(extIndex + 1);\n }\n\n /**\n * Strip the filename extension from the given path,\n * e.g. \"mypath/myfile.txt\" -> \"mypath/myfile\".\n * @param path the file path (may be null)\n * @return the path with stripped filename extension,\n * or null if none\n */\n public static String stripFilenameExtension(String path) {\n if (path == null) {\n return null;\n }\n int extIndex = path.lastIndexOf(EXTENSION_SEPARATOR);\n if (extIndex == -1) {\n return path;\n }\n int folderIndex = path.lastIndexOf(FOLDER_SEPARATOR);\n if (folderIndex > extIndex) {\n return path;\n }\n return path.substring(0, extIndex);\n }\n\n /**\n * Apply the given relative path to the given path,\n * assuming standard Java folder separation (i.e. \"/\" separators).\n * @param path the path to start from (usually a full file path)\n * @param relativePath the relative path to apply\n * (relative to the full file path above)\n * @return the full file path that results from applying the relative path\n */\n public static String applyRelativePath(String path, String relativePath) {\n int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);\n if (separatorIndex != -1) {\n String newPath = path.substring(0, separatorIndex);\n if (!relativePath.startsWith(FOLDER_SEPARATOR)) {\n newPath += FOLDER_SEPARATOR;\n }\n return newPath + relativePath;\n }\n else {\n return relativePath;\n }\n }\n\n /**\n * Normalize the path by suppressing sequences like \"path/..\" and\n * inner simple dots.\n * The result is convenient for path comparison. For other uses,\n * notice that Windows separators (\"\\\") are replaced by simple slashes.\n * @param path the original path\n * @return the normalized path\n */\n public static String cleanPath(String path) {\n if (path == null) {\n return null;\n }\n String pathToUse = replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);\n\n // Strip prefix from path to analyze, to not treat it as part of the\n // first path element. This is necessary to correctly parse paths like\n // \"file:core/../core/io/Resource.class\", where the \"..\" should just\n // strip the first \"core\" directory while keeping the \"file:\" prefix.\n int prefixIndex = pathToUse.indexOf(\":\");\n String prefix = \"\";\n if (prefixIndex != -1) {\n prefix = pathToUse.substring(0, prefixIndex + 1);\n pathToUse = pathToUse.substring(prefixIndex + 1);\n }\n if (pathToUse.startsWith(FOLDER_SEPARATOR)) {\n prefix = prefix + FOLDER_SEPARATOR;\n pathToUse = pathToUse.substring(1);\n }\n\n String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR);\n List This is the inverse operation of {@link java.util.Locale#toString Locale's toString}.\n * @param localeString the locale string, following The order of elements in the original arrays is preserved.\n * @param array1 the first array (can be The order of elements in the original arrays is preserved\n * (with the exception of overlapping elements, which are only\n * included on their first occurrence).\n * @param array1 the first array (can be Will trim both the key and value before adding them to the\n * Will trim both the key and value before adding them to the\n * The given delimiters string is supposed to consist of any number of\n * delimiter characters. Each of those characters can be used to separate\n * tokens. A delimiter is always a single character; for multi-character\n * delimiters, consider using The given delimiters string is supposed to consist of any number of\n * delimiter characters. Each of those characters can be used to separate\n * tokens. A delimiter is always a single character; for multi-character\n * delimiters, consider using A single delimiter can consists of more than one character: It will still\n * be considered as single delimiter string, rather than as bunch of potential\n * delimiter characters - in contrast to A single delimiter can consists of more than one character: It will still\n * be considered as single delimiter string, rather than as bunch of potential\n * delimiter characters - in contrast to Checks whether two arrays are the same length, treating Operations on arrays, primitive arrays (like This class tries to handle #ThreadSafe# ArrayUtils instances should NOT be constructed in standard programming.\n * Instead, the class should be used as This constructor is public to permit tools that require a JavaBean instance\n * to operate. Converts the given array into a {@link Map}. Each element of the array\n * must be either a {@link Entry} or an Array, containing at least two\n * elements, where the first element is used as key and the second as\n * value. This method can be used to initialize: This method returns Shallow clones an array returning a typecast result and handling\n * The objects in the array are not cloned, thus there is no special\n * handling for multi-dimensional arrays. This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Clones an array returning a typecast result and handling\n * This method returns Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Defensive programming technique to change a This method returns an empty array for a As a memory optimizing technique an empty array passed in will be overridden with\n * the empty Produces a new array containing the elements between\n * the start and end indices. The start index is inclusive, the end index exclusive.\n * Null array input produces null output. The component type of the subarray is always the same as\n * that of the input array. Thus, if the input is an array of type\n * Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Produces a new The start index is inclusive, the end index exclusive.\n * Null array input produces null output. Checks whether two arrays are the same length, treating\n * Any multi-dimensional aspects of the arrays are ignored. Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Checks whether two arrays are the same length, treating\n * Returns the length of the specified array.\n * This method can deal with If the input array is Checks whether two arrays are the same type taking into account\n * multi-dimensional arrays. Reverses the order of the given array. There is no special handling for multi-dimensional arrays. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Reverses the order of the given array. This method does nothing for a Finds the index of the given object in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given object in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given object within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given object in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the object is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value within a given tolerance in the array.\n * This method will return the index of the first value which falls between the region\n * defined by valueToFind - tolerance and valueToFind + tolerance. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index.\n * This method will return the index of the first value which falls between the region\n * defined by valueToFind - tolerance and valueToFind + tolerance. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within a given tolerance in the array.\n * This method will return the index of the last value which falls between the region\n * defined by valueToFind - tolerance and valueToFind + tolerance. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index.\n * This method will return the index of the last value which falls between the region\n * defined by valueToFind - tolerance and valueToFind + tolerance. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Checks if a value falling within the given tolerance is in the\n * given array. If the array contains a value within the inclusive range\n * defined by (value - tolerance) to (value + tolerance). The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Finds the index of the given value in the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex is treated as zero. A startIndex larger than the array\n * length will return {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value within the array. This method returns {@link #INDEX_NOT_FOUND} ( Finds the last index of the given value in the array starting at the given index. This method returns {@link #INDEX_NOT_FOUND} ( A negative startIndex will return {@link #INDEX_NOT_FOUND} ( Checks if the value is in the given array. The method returns Converts an array of object Characters to primitives. This method returns Converts an array of object Character to primitives handling This method returns Converts an array of primitive chars to objects. This method returns Converts an array of object Longs to primitives. This method returns Converts an array of object Long to primitives handling This method returns Converts an array of primitive longs to objects. This method returns Converts an array of object Integers to primitives. This method returns Converts an array of object Integer to primitives handling This method returns Converts an array of primitive ints to objects. This method returns Converts an array of object Shorts to primitives. This method returns Converts an array of object Short to primitives handling This method returns Converts an array of primitive shorts to objects. This method returns Converts an array of object Bytes to primitives. This method returns Converts an array of object Bytes to primitives handling This method returns Converts an array of primitive bytes to objects. This method returns Converts an array of object Doubles to primitives. This method returns Converts an array of object Doubles to primitives handling This method returns Converts an array of primitive doubles to objects. This method returns Converts an array of object Floats to primitives. This method returns Converts an array of object Floats to primitives handling This method returns Converts an array of primitive floats to objects. This method returns Converts an array of object Booleans to primitives. This method returns Converts an array of object Booleans to primitives handling This method returns Converts an array of primitive booleans to objects. This method returns Checks if an array of Objects is empty or Checks if an array of primitive longs is empty or Checks if an array of primitive ints is empty or Checks if an array of primitive shorts is empty or Checks if an array of primitive chars is empty or Checks if an array of primitive bytes is empty or Checks if an array of primitive doubles is empty or Checks if an array of primitive floats is empty or Checks if an array of primitive booleans is empty or Checks if an array of Objects is not empty or not Checks if an array of primitive longs is not empty or not Checks if an array of primitive ints is not empty or not Checks if an array of primitive shorts is not empty or not Checks if an array of primitive chars is not empty or not Checks if an array of primitive bytes is not empty or not Checks if an array of primitive doubles is not empty or not Checks if an array of primitive floats is not empty or not Checks if an array of primitive booleans is not empty or not Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Adds all the elements of the given arrays into a new array. The new array contains all of the element of Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Copies the given array and adds the given element at the end of the new array. The new array contains the same elements of the input\n * array plus the given element in the last position. The component type of\n * the new array is the same as that of the input array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Inserts the specified element at the specified position in the array.\n * Shifts the element currently at that position (if any) and any subsequent\n * elements to the right (adds one to their indices). This method returns a new array with the same elements of the input\n * array plus the given element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is Removes the first occurrence of the specified element from the\n * specified array. All subsequent elements are shifted to the left\n * (substracts one from their indices). If the array doesn't contains\n * such an element, no elements are removed from the array. This method returns a new array with the same elements of the input\n * array except the first occurrence of the specified element. The component\n * type of the returned array is always the same as that of the input\n * array. Removes the element at the specified position from the specified array.\n * All subsequent elements are shifted to the left (substracts one from\n * their indices). This method returns a new array with the same elements of the input\n * array except the element on the specified position. The component\n * type of the returned array is always the same as that of the input\n * array. If the input array is localeString value into a {@link java.util.Locale}.\n * Locale's\n * toString() format (\"en\", \"en_UK\", etc);\n * also accepts spaces as separators, as an alternative to underscores\n * @return a corresponding Locale instance\n */\n public static Locale parseLocaleString(String localeString) {\n String[] parts = tokenizeToStringArray(localeString, \"_ \", false, false);\n String language = (parts.length > 0 ? parts[0] : \"\");\n String country = (parts.length > 1 ? parts[1] : \"\");\n validateLocalePart(language);\n validateLocalePart(country);\n String variant = \"\";\n if (parts.length >= 2) {\n // There is definitely a variant, and it is everything after the country\n // code sans the separator between the country code and the variant.\n int endIndexOfCountryCode = localeString.indexOf(country) + country.length();\n // Strip off any leading '_' and whitespace, what's left is the variant.\n variant = trimLeadingWhitespace(localeString.substring(endIndexOfCountryCode));\n if (variant.startsWith(\"_\")) {\n variant = trimLeadingCharacter(variant, '_');\n }\n }\n return (language.length() > 0 ? new Locale(language, country, variant) : null);\n }\n\n private static void validateLocalePart(String localePart) {\n for (int i = 0; i < localePart.length(); i++) {\n char ch = localePart.charAt(i);\n if (ch != '_' && ch != ' ' && !Character.isLetterOrDigit(ch)) {\n throw new IllegalArgumentException(\n \"Locale part \\\"\" + localePart + \"\\\" contains invalid characters\");\n }\n }\n }\n\n /**\n * Determine the RFC 3066 compliant language tag,\n * as used for the HTTP \"Accept-Language\" header.\n * @param locale the Locale to transform to a language tag\n * @return the RFC 3066 compliant language tag as String\n */\n public static String toLanguageTag(Locale locale) {\n return locale.getLanguage() + (hasText(locale.getCountry()) ? \"-\" + locale.getCountry() : \"\");\n }\n\n\n //---------------------------------------------------------------------\n // Convenience methods for working with String arrays\n //---------------------------------------------------------------------\n\n /**\n * Append the given String to the given String array, returning a new array\n * consisting of the input array contents plus the given String.\n * @param array the array to append to (can be null)\n * @param str the String to append\n * @return the new array (never null)\n */\n public static String[] addStringToArray(String[] array, String str) {\n if (Objects.isEmpty(array)) {\n return new String[] {str};\n }\n String[] newArr = new String[array.length + 1];\n System.arraycopy(array, 0, newArr, 0, array.length);\n newArr[array.length] = str;\n return newArr;\n }\n\n /**\n * Concatenate the given String arrays into one,\n * with overlapping array elements included twice.\n * null)\n * @param array2 the second array (can be null)\n * @return the new array (null if both given arrays were null)\n */\n public static String[] concatenateStringArrays(String[] array1, String[] array2) {\n if (Objects.isEmpty(array1)) {\n return array2;\n }\n if (Objects.isEmpty(array2)) {\n return array1;\n }\n String[] newArr = new String[array1.length + array2.length];\n System.arraycopy(array1, 0, newArr, 0, array1.length);\n System.arraycopy(array2, 0, newArr, array1.length, array2.length);\n return newArr;\n }\n\n /**\n * Merge the given String arrays into one, with overlapping\n * array elements only included once.\n * null)\n * @param array2 the second array (can be null)\n * @return the new array (null if both given arrays were null)\n */\n public static String[] mergeStringArrays(String[] array1, String[] array2) {\n if (Objects.isEmpty(array1)) {\n return array2;\n }\n if (Objects.isEmpty(array2)) {\n return array1;\n }\n Listnull)\n */\n public static String[] sortStringArray(String[] array) {\n if (Objects.isEmpty(array)) {\n return new String[0];\n }\n Arrays.sort(array);\n return array;\n }\n\n /**\n * Copy the given Collection into a String array.\n * The Collection must contain String elements only.\n * @param collection the Collection to copy\n * @return the String array (null if the passed-in\n * Collection was null)\n */\n public static String[] toStringArray(Collectionnull if the passed-in\n * Enumeration was null)\n */\n public static String[] toStringArray(EnumerationString.trim() on each of them.\n * @param array the original String array\n * @return the resulting array (of the same size) with trimmed elements\n */\n public static String[] trimArrayElements(String[] array) {\n if (Objects.isEmpty(array)) {\n return new String[0];\n }\n String[] result = new String[array.length];\n for (int i = 0; i < array.length; i++) {\n String element = array[i];\n result[i] = (element != null ? element.trim() : null);\n }\n return result;\n }\n\n /**\n * Remove duplicate Strings from the given array.\n * Also sorts the array, as it uses a TreeSet.\n * @param array the String array\n * @return an array without duplicates, in natural sort order\n */\n public static String[] removeDuplicateStrings(String[] array) {\n if (Objects.isEmpty(array)) {\n return array;\n }\n Setnull if the delimiter wasn't found in the given input String\n */\n public static String[] split(String toSplit, String delimiter) {\n if (!hasLength(toSplit) || !hasLength(delimiter)) {\n return null;\n }\n int offset = toSplit.indexOf(delimiter);\n if (offset < 0) {\n return null;\n }\n String beforeDelimiter = toSplit.substring(0, offset);\n String afterDelimiter = toSplit.substring(offset + delimiter.length());\n return new String[] {beforeDelimiter, afterDelimiter};\n }\n\n /**\n * Take an array Strings and split each element based on the given delimiter.\n * A Properties instance is then generated, with the left of the\n * delimiter providing the key, and the right of the delimiter providing the value.\n * Properties instance.\n * @param array the array to process\n * @param delimiter to split each element using (typically the equals symbol)\n * @return a Properties instance representing the array contents,\n * or null if the array to process was null or empty\n */\n public static Properties splitArrayElementsIntoProperties(String[] array, String delimiter) {\n return splitArrayElementsIntoProperties(array, delimiter, null);\n }\n\n /**\n * Take an array Strings and split each element based on the given delimiter.\n * A Properties instance is then generated, with the left of the\n * delimiter providing the key, and the right of the delimiter providing the value.\n * Properties instance.\n * @param array the array to process\n * @param delimiter to split each element using (typically the equals symbol)\n * @param charsToDelete one or more characters to remove from each element\n * prior to attempting the split operation (typically the quotation mark\n * symbol), or null if no removal should occur\n * @return a Properties instance representing the array contents,\n * or null if the array to process was null or empty\n */\n public static Properties splitArrayElementsIntoProperties(\n String[] array, String delimiter, String charsToDelete) {\n\n if (Objects.isEmpty(array)) {\n return null;\n }\n Properties result = new Properties();\n for (String element : array) {\n if (charsToDelete != null) {\n element = deleteAny(element, charsToDelete);\n }\n String[] splittedElement = split(element, delimiter);\n if (splittedElement == null) {\n continue;\n }\n result.setProperty(splittedElement[0].trim(), splittedElement[1].trim());\n }\n return result;\n }\n\n /**\n * Tokenize the given String into a String array via a StringTokenizer.\n * Trims tokens and omits empty tokens.\n * delimitedListToStringArray\n * @param str the String to tokenize\n * @param delimiters the delimiter characters, assembled as String\n * (each of those characters is individually considered as delimiter).\n * @return an array of the tokens\n * @see java.util.StringTokenizer\n * @see java.lang.String#trim()\n * @see #delimitedListToStringArray\n */\n public static String[] tokenizeToStringArray(String str, String delimiters) {\n return tokenizeToStringArray(str, delimiters, true, true);\n }\n\n /**\n * Tokenize the given String into a String array via a StringTokenizer.\n * delimitedListToStringArray\n * @param str the String to tokenize\n * @param delimiters the delimiter characters, assembled as String\n * (each of those characters is individually considered as delimiter)\n * @param trimTokens trim the tokens via String's trim\n * @param ignoreEmptyTokens omit empty tokens from the result array\n * (only applies to tokens that are empty after trimming; StringTokenizer\n * will not consider subsequent delimiters as token in the first place).\n * @return an array of the tokens (null if the input String\n * was null)\n * @see java.util.StringTokenizer\n * @see java.lang.String#trim()\n * @see #delimitedListToStringArray\n */\n public static String[] tokenizeToStringArray(\n String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {\n\n if (str == null) {\n return null;\n }\n StringTokenizer st = new StringTokenizer(str, delimiters);\n ListtokenizeToStringArray.\n * @param str the input String\n * @param delimiter the delimiter between elements (this is a single delimiter,\n * rather than a bunch individual delimiter characters)\n * @return an array of the tokens in the list\n * @see #tokenizeToStringArray\n */\n public static String[] delimitedListToStringArray(String str, String delimiter) {\n return delimitedListToStringArray(str, delimiter, null);\n }\n\n /**\n * Take a String which is a delimited list and convert it to a String array.\n * tokenizeToStringArray.\n * @param str the input String\n * @param delimiter the delimiter between elements (this is a single delimiter,\n * rather than a bunch individual delimiter characters)\n * @param charsToDelete a set of characters to delete. Useful for deleting unwanted\n * line breaks: e.g. \"\\r\\n\\f\" will delete all new lines and line feeds in a String.\n * @return an array of the tokens in the list\n * @see #tokenizeToStringArray\n */\n public static String[] delimitedListToStringArray(String str, String delimiter, String charsToDelete) {\n if (str == null) {\n return new String[0];\n }\n if (delimiter == null) {\n return new String[] {str};\n }\n ListtoString() implementations.\n * @param coll the Collection to display\n * @param delim the delimiter to use (probably a \",\")\n * @param prefix the String to start each element with\n * @param suffix the String to end each element with\n * @return the delimited String\n */\n public static String collectionToDelimitedString(Collection> coll, String delim, String prefix, String suffix) {\n if (Collections.isEmpty(coll)) {\n return \"\";\n }\n StringBuilder sb = new StringBuilder();\n Iterator> it = coll.iterator();\n while (it.hasNext()) {\n sb.append(prefix).append(it.next()).append(suffix);\n if (it.hasNext()) {\n sb.append(delim);\n }\n }\n return sb.toString();\n }\n\n /**\n * Convenience method to return a Collection as a delimited (e.g. CSV)\n * String. E.g. useful for toString() implementations.\n * @param coll the Collection to display\n * @param delim the delimiter to use (probably a \",\")\n * @return the delimited String\n */\n public static String collectionToDelimitedString(Collection> coll, String delim) {\n return collectionToDelimitedString(coll, delim, \"\", \"\");\n }\n\n /**\n * Convenience method to return a Collection as a CSV String.\n * E.g. useful for toString() implementations.\n * @param coll the Collection to display\n * @return the delimited String\n */\n public static String collectionToCommaDelimitedString(Collection> coll) {\n return collectionToDelimitedString(coll, \",\");\n }\n\n /**\n * Convenience method to return a String array as a delimited (e.g. CSV)\n * String. E.g. useful for toString() implementations.\n * @param arr the array to display\n * @param delim the delimiter to use (probably a \",\")\n * @return the delimited String\n */\n public static String arrayToDelimitedString(Object[] arr, String delim) {\n if (Objects.isEmpty(arr)) {\n return \"\";\n }\n if (arr.length == 1) {\n return Objects.nullSafeToString(arr[0]);\n }\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < arr.length; i++) {\n if (i > 0) {\n sb.append(delim);\n }\n sb.append(arr[i]);\n }\n return sb.toString();\n }\n\n /**\n * Convenience method to return a String array as a CSV String.\n * E.g. useful for toString() implementations.\n * @param arr the array to display\n * @return the delimited String\n */\n public static String arrayToCommaDelimitedString(Object[] arr) {\n return arrayToDelimitedString(arr, \",\");\n }\n\n}\n\n",
"file_name": "Strings.java",
"human_label": "Trim each element in the given string array and return the resulting array.",
"level": "self_contained",
"lineno": "826",
"name": "trimArrayElements",
"oracle_context": "{ \"apis\" : \"[isEmpty, trim]\", \"classes\" : \"[String[], String]\", \"vars\" : \"[length]\" }",
"package": "io.jsonwebtoken.lang",
"project": "jjwt-master"
},
{
"_id": "6367670b1a6d9265ec017a00",
"all_context": "{ \"class_level\" : \"import java.lang.reflect.Array;\\nimport java.util.ArrayList;\\nimport java.util.HashMap;\\nimport java.util.Map;\\nimport java.util.Map.Entry;\\nObject[] EMPTY_OBJECT_ARRAY;\\nClass>[] EMPTY_CLASS_ARRAY;\\nString[] EMPTY_STRING_ARRAY;\\nlong[] EMPTY_LONG_ARRAY;\\nLong[] EMPTY_LONG_OBJECT_ARRAY;\\nint[] EMPTY_INT_ARRAY;\\nInteger[] EMPTY_INTEGER_OBJECT_ARRAY;\\nshort[] EMPTY_SHORT_ARRAY;\\nShort[] EMPTY_SHORT_OBJECT_ARRAY;\\nbyte[] EMPTY_BYTE_ARRAY;\\nByte[] EMPTY_BYTE_OBJECT_ARRAY;\\ndouble[] EMPTY_DOUBLE_ARRAY;\\nDouble[] EMPTY_DOUBLE_OBJECT_ARRAY;\\nfloat[] EMPTY_FLOAT_ARRAY;\\nFloat[] EMPTY_FLOAT_OBJECT_ARRAY;\\nboolean[] EMPTY_BOOLEAN_ARRAY;\\nBoolean[] EMPTY_BOOLEAN_OBJECT_ARRAY;\\nchar[] EMPTY_CHAR_ARRAY;\\nCharacter[] EMPTY_CHARACTER_OBJECT_ARRAY;\\nint INDEX_NOT_FOUND;\\nArrayUtils();\\nclone(Object[] array);\\nclone(long[] array);\\nclone(int[] array);\\nclone(short[] array);\\nclone(char[] array);\\nclone(byte[] array);\\nclone(double[] array);\\nclone(float[] array);\\nclone(boolean[] array);\\nclone(String[] array);\\nnullToEmpty(Object[] array);\\nnullToEmpty(String[] array);\\nnullToEmpty(long[] array);\\nnullToEmpty(int[] array);\\nnullToEmpty(short[] array);\\nnullToEmpty(char[] array);\\nnullToEmpty(byte[] array);\\nnullToEmpty(double[] array);\\nnullToEmpty(float[] array);\\nnullToEmpty(boolean[] array);\\nnullToEmpty(Long[] array);\\nnullToEmpty(Integer[] array);\\nnullToEmpty(Short[] array);\\nnullToEmpty(Character[] array);\\nnullToEmpty(Byte[] array);\\nnullToEmpty(Double[] array);\\nnullToEmpty(Float[] array);\\nnullToEmpty(Boolean[] array);\\nsubarray(Object[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(long[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(int[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(short[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(char[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(byte[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(double[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(float[] array,int startIndexInclusive,int endIndexExclusive);\\nsubarray(boolean[] array,int startIndexInclusive,int endIndexExclusive);\\nisSameLength(Object[] array1,Object[] array2);\\nisSameLength(long[] array1,long[] array2);\\nisSameLength(int[] array1,int[] array2);\\nisSameLength(short[] array1,short[] array2);\\nisSameLength(char[] array1,char[] array2);\\nisSameLength(byte[] array1,byte[] array2);\\nisSameLength(double[] array1,double[] array2);\\nisSameLength(float[] array1,float[] array2);\\nisSameLength(boolean[] array1,boolean[] array2);\\ngetLength(Object array);\\nisSameType(Object array1,Object array2);\\nreverse(Object[] array);\\nreverse(long[] array);\\nreverse(int[] array);\\nreverse(short[] array);\\nreverse(char[] array);\\nreverse(byte[] array);\\nreverse(double[] array);\\nreverse(float[] array);\\nreverse(boolean[] array);\\nindexOf(Object[] array,Object objectToFind);\\nindexOf(Object[] array,Object objectToFind,int startIndex);\\nlastIndexOf(Object[] array,Object objectToFind);\\nlastIndexOf(Object[] array,Object objectToFind,int startIndex);\\ncontains(Object[] array,Object objectToFind);\\nindexOf(long[] array,long valueToFind);\\nindexOf(long[] array,long valueToFind,int startIndex);\\nlastIndexOf(long[] array,long valueToFind);\\nlastIndexOf(long[] array,long valueToFind,int startIndex);\\ncontains(long[] array,long valueToFind);\\nindexOf(int[] array,int valueToFind);\\nindexOf(int[] array,int valueToFind,int startIndex);\\nlastIndexOf(int[] array,int valueToFind);\\nlastIndexOf(int[] array,int valueToFind,int startIndex);\\ncontains(int[] array,int valueToFind);\\nindexOf(short[] array,short valueToFind);\\nindexOf(short[] array,short valueToFind,int startIndex);\\nlastIndexOf(short[] array,short valueToFind);\\nlastIndexOf(short[] array,short valueToFind,int startIndex);\\ncontains(short[] array,short valueToFind);\\nindexOf(char[] array,char valueToFind);\\nindexOf(char[] array,char valueToFind,int startIndex);\\nlastIndexOf(char[] array,char valueToFind);\\nlastIndexOf(char[] array,char valueToFind,int startIndex);\\ncontains(char[] array,char valueToFind);\\nindexOf(byte[] array,byte valueToFind);\\nindexOf(byte[] array,byte valueToFind,int startIndex);\\nlastIndexOf(byte[] array,byte valueToFind);\\nlastIndexOf(byte[] array,byte valueToFind,int startIndex);\\ncontains(byte[] array,byte valueToFind);\\nindexOf(double[] array,double valueToFind);\\nindexOf(double[] array,double valueToFind,double tolerance);\\nindexOf(double[] array,double valueToFind,int startIndex);\\nindexOf(double[] array,double valueToFind,int startIndex,double tolerance);\\nlastIndexOf(double[] array,double valueToFind);\\nlastIndexOf(double[] array,double valueToFind,double tolerance);\\nlastIndexOf(double[] array,double valueToFind,int startIndex);\\nlastIndexOf(double[] array,double valueToFind,int startIndex,double tolerance);\\ncontains(double[] array,double valueToFind);\\ncontains(double[] array,double valueToFind,double tolerance);\\nindexOf(float[] array,float valueToFind);\\nindexOf(float[] array,float valueToFind,int startIndex);\\nlastIndexOf(float[] array,float valueToFind);\\nlastIndexOf(float[] array,float valueToFind,int startIndex);\\ncontains(float[] array,float valueToFind);\\nindexOf(boolean[] array,boolean valueToFind);\\nindexOf(boolean[] array,boolean valueToFind,int startIndex);\\nlastIndexOf(boolean[] array,boolean valueToFind);\\nlastIndexOf(boolean[] array,boolean valueToFind,int startIndex);\\ncontains(boolean[] array,boolean valueToFind);\\ntoPrimitive(Character[] array);\\ntoPrimitive(Character[] array,char valueForNull);\\ntoObject(char[] array);\\ntoPrimitive(Long[] array);\\ntoPrimitive(Long[] array,long valueForNull);\\ntoObject(long[] array);\\ntoPrimitive(Integer[] array);\\ntoPrimitive(Integer[] array,int valueForNull);\\ntoObject(int[] array);\\ntoPrimitive(Short[] array);\\ntoPrimitive(Short[] array,short valueForNull);\\ntoObject(short[] array);\\ntoPrimitive(Byte[] array);\\ntoPrimitive(Byte[] array,byte valueForNull);\\ntoObject(byte[] array);\\ntoPrimitive(Double[] array);\\ntoPrimitive(Double[] array,double valueForNull);\\ntoObject(double[] array);\\ntoPrimitive(Float[] array);\\ntoPrimitive(Float[] array,float valueForNull);\\ntoObject(float[] array);\\ntoPrimitive(Boolean[] array);\\ntoPrimitive(Boolean[] array,boolean valueForNull);\\ntoObject(boolean[] array);\\nisEmpty(Object[] array);\\nisEmpty(long[] array);\\nisEmpty(int[] array);\\nisEmpty(short[] array);\\nisEmpty(char[] array);\\nisEmpty(byte[] array);\\nisEmpty(double[] array);\\nisEmpty(float[] array);\\nisEmpty(boolean[] array);\\nisNotEmpty(Object[] array);\\nisNotEmpty(long[] array);\\nisNotEmpty(int[] array);\\nisNotEmpty(short[] array);\\nisNotEmpty(char[] array);\\nisNotEmpty(byte[] array);\\nisNotEmpty(double[] array);\\nisNotEmpty(float[] array);\\nisNotEmpty(boolean[] array);\\naddAll(Object[] array1,Object[] array2);\\naddAll(boolean[] array1,boolean[] array2);\\naddAll(char[] array1,char[] array2);\\naddAll(byte[] array1,byte[] array2);\\naddAll(short[] array1,short[] array2);\\naddAll(int[] array1,int[] array2);\\naddAll(long[] array1,long[] array2);\\naddAll(float[] array1,float[] array2);\\naddAll(double[] array1,double[] array2);\\naddAll(String[] array1,String[] array2);\\nadd(T[] array,T element);\\nadd(boolean[] array,boolean element);\\nadd(byte[] array,byte element);\\nadd(char[] array,char element);\\nadd(double[] array,double element);\\nadd(float[] array,float element);\\nadd(int[] array,int element);\\nadd(long[] array,long element);\\nadd(short[] array,short element);\\ncopyArrayGrow1(Object array,Class newArrayComponentType);\\nadd(Object[] array,int index,Object element);\\nadd(boolean[] array,int index,boolean element);\\nadd(char[] array,int index,char element);\\nadd(byte[] array,int index,byte element);\\nadd(short[] array,int index,short element);\\nadd(int[] array,int index,int element);\\nadd(long[] array,int index,long element);\\nadd(float[] array,int index,float element);\\nadd(double[] array,int index,double element);\\nadd(Object array,int index,Object element,Class clss);\\nremove(Object[] array,int index);\\nremoveElement(Object[] array,Object element);\\nremove(boolean[] array,int index);\\nremoveElement(boolean[] array,boolean element);\\nremove(byte[] array,int index);\\nremoveElement(byte[] array,byte element);\\nremove(char[] array,int index);\\nremoveElement(char[] array,char element);\\nremove(double[] array,int index);\\nremoveElement(double[] array,double element);\\nremove(float[] array,int index);\\nremoveElement(float[] array,float element);\\nremove(int[] array,int index);\\nremoveElement(int[] array,int element);\\nremove(long[] array,int index);\\nremoveElement(long[] array,long element);\\nremove(short[] array,int index);\\nremoveElement(short[] array,short element);\\nremove(Object array,int index);\\nclearNull(Object[] arr);\\ntoMap(Object[] array);\\n\", \"repo_level\" : \"\" }",
"class_name": "ArrayUtils",
"code": "public static boolean isSameLength(final byte[] array1,final byte[] array2){\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n}\n",
"docstring": "/** \n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treatingnull as an empty array\n */\n",
"end_lineno": "1130",
"file_content": "/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage net.hasor.utils;\nimport java.lang.reflect.Array;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Map.Entry;\n\n/**\n * int[]) and\n * primitive wrapper arrays (like Integer[]).null input gracefully.\n * An exception will not be thrown for a null\n * array input. However, an Object array that contains a null\n * element may throw an exception. Each method documents its behaviour.Object array. */\n public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];\n /** An empty immutable Class array. */\n public static final Class>[] EMPTY_CLASS_ARRAY = new Class[0];\n /** An empty immutable String array. */\n public static final String[] EMPTY_STRING_ARRAY = new String[0];\n /** An empty immutable long array. */\n public static final long[] EMPTY_LONG_ARRAY = new long[0];\n /** An empty immutable Long array. */\n public static final Long[] EMPTY_LONG_OBJECT_ARRAY = new Long[0];\n /** An empty immutable int array. */\n public static final int[] EMPTY_INT_ARRAY = new int[0];\n /** An empty immutable Integer array. */\n public static final Integer[] EMPTY_INTEGER_OBJECT_ARRAY = new Integer[0];\n /** An empty immutable short array. */\n public static final short[] EMPTY_SHORT_ARRAY = new short[0];\n /** An empty immutable Short array. */\n public static final Short[] EMPTY_SHORT_OBJECT_ARRAY = new Short[0];\n /** An empty immutable byte array. */\n public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];\n /** An empty immutable Byte array. */\n public static final Byte[] EMPTY_BYTE_OBJECT_ARRAY = new Byte[0];\n /** An empty immutable double array. */\n public static final double[] EMPTY_DOUBLE_ARRAY = new double[0];\n /** An empty immutable Double array. */\n public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY = new Double[0];\n /** An empty immutable float array. */\n public static final float[] EMPTY_FLOAT_ARRAY = new float[0];\n /** An empty immutable Float array. */\n public static final Float[] EMPTY_FLOAT_OBJECT_ARRAY = new Float[0];\n /** An empty immutable boolean array. */\n public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];\n /** An empty immutable Boolean array. */\n public static final Boolean[] EMPTY_BOOLEAN_OBJECT_ARRAY = new Boolean[0];\n /** An empty immutable char array. */\n public static final char[] EMPTY_CHAR_ARRAY = new char[0];\n /** An empty immutable Character array. */\n public static final Character[] EMPTY_CHARACTER_OBJECT_ARRAY = new Character[0];\n /**\n * The index value when an element is not found in a list or array: -1.\n * This value is returned by methods in this class and can also be used in comparisons with values returned by\n * various method from {@link java.util.List}.\n */\n public static final int INDEX_NOT_FOUND = -1;\n\n /**\n * ArrayUtils.clone(new int[] {2}).\n * // Create a Map mapping colors.\n * Map colorMap = ArrayUtils.toMap(new String[][] {{\n * {\"RED\", \"#FF0000\"},\n * {\"GREEN\", \"#00FF00\"},\n * {\"BLUE\", \"#0000FF\"}});\n * \n *\n * null for a null input array.null\n * @return a Map that was created from the array\n * @throws IllegalArgumentException if one element of this Array is\n * itself an Array containing less then two elements\n * @throws IllegalArgumentException if the array contains elements other\n * than {@link Entry} and an Array\n */\n public static Map toMap(final Object[] array) {\n if (array == null) {\n return null;\n }\n final Map map = new HashMap((int) (array.length * 1.5));\n for (int i = 0; i < array.length; i++) {\n Object object = array[i];\n if (object instanceof Entry) {\n Entry entry = (Entry) object;\n map.put(entry.getKey(), entry.getValue());\n } else if (object instanceof Object[]) {\n Object[] entry = (Object[]) object;\n if (entry.length < 2) {\n throw new IllegalArgumentException(\"Array element \" + i + \", '\" + object + \"', has a length less than 2\");\n }\n map.put(entry[0], entry[1]);\n } else {\n throw new IllegalArgumentException(\"Array element \" + i + \", '\" + object + \"', is neither of type Map.Entry nor an Array\");\n }\n }\n return map;\n }\n // Clone\n //-----------------------------------------------------------------------\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static Object[] clone(final Object[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static long[] clone(final long[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static int[] clone(final int[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static short[] clone(final short[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static char[] clone(final char[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static byte[] clone(final byte[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static double[] clone(final double[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static float[] clone(final float[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static boolean[] clone(final boolean[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n /**\n * null.null for a null input array.null\n * @return the cloned array, null if null input\n */\n public static String[] clone(final String[] array) {\n if (array == null) {\n return null;\n }\n return array.clone();\n }\n // nullToEmpty\n //-----------------------------------------------------------------------\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Object[] nullToEmpty(final Object[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static String[] nullToEmpty(final String[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_STRING_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static long[] nullToEmpty(final long[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_LONG_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static int[] nullToEmpty(final int[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_INT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static short[] nullToEmpty(final short[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_SHORT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static char[] nullToEmpty(final char[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_CHAR_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static byte[] nullToEmpty(final byte[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_BYTE_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static double[] nullToEmpty(final double[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_DOUBLE_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static float[] nullToEmpty(final float[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_FLOAT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static boolean[] nullToEmpty(final boolean[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_BOOLEAN_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Long[] nullToEmpty(final Long[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_LONG_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Integer[] nullToEmpty(final Integer[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Short[] nullToEmpty(final Short[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Character[] nullToEmpty(final Character[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Byte[] nullToEmpty(final Byte[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Double[] nullToEmpty(final Double[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Float[] nullToEmpty(final Float[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY;\n }\n return array;\n }\n\n /**\n * null\n * reference to an empty one.null input array.public static references in this class.null or empty\n * @return the same array, public static empty array if null or empty input\n * @since 2.5\n */\n public static Boolean[] nullToEmpty(final Boolean[] array) {\n if (array == null || array.length == 0) {\n return ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY;\n }\n return array;\n }\n // Subarrays\n //-----------------------------------------------------------------------\n\n /**\n * Date, the following usage is envisaged:\n * Date[] someDates = (Date[])ArrayUtils.subarray(allDates, 2, 5);\n *
\n *\n * @param array the array\n * @param startIndexInclusive the starting index. Undervalue (<0)\n * is promoted to 0, overvalue (>array.length) results\n * in an empty array.\n * @param endIndexExclusive elements up to endIndex-1 are present in the\n * returned subarray. Undervalue (< startIndex) produces\n * empty array, overvalue (>array.length) is demoted to\n * array length.\n * @return a new array containing the elements between\n * the start and end indices.\n * @since 2.1\n */\n public static Object[] subarray(final Object[] array, int startIndexInclusive, int endIndexExclusive) {\n if (array == null) {\n return null;\n }\n if (startIndexInclusive < 0) {\n startIndexInclusive = 0;\n }\n if (endIndexExclusive > array.length) {\n endIndexExclusive = array.length;\n }\n int newSize = endIndexExclusive - startIndexInclusive;\n Class> type = array.getClass().getComponentType();\n if (newSize <= 0) {\n return (Object[]) Array.newInstance(type, 0);\n }\n Object[] subarray = (Object[]) Array.newInstance(type, newSize);\n System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);\n return subarray;\n }\n\n /**\n * long array containing the elements\n * between the start and end indices.int array containing the elements\n * between the start and end indices.short array containing the elements\n * between the start and end indices.char array containing the elements\n * between the start and end indices.byte array containing the elements\n * between the start and end indices.double array containing the elements\n * between the start and end indices.float array containing the elements\n * between the start and end indices.boolean array containing the elements\n * between the start and end indices.null arrays as length 0.\n *\n * null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final Object[] array1, final Object[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final long[] array1, final long[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final int[] array1, final int[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final short[] array1, final short[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final char[] array1, final char[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final byte[] array1, final byte[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final double[] array1, final double[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final float[] array1, final float[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n\n /**\n * null arrays as length 0.null\n * @param array2 the second array, may be null\n * @return true if length of arrays matches, treating\n * null as an empty array\n */\n public static boolean isSameLength(final boolean[] array1, final boolean[] array2) {\n if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) {\n return false;\n }\n return true;\n }\n //-----------------------------------------------------------------------\n\n /**\n * Object arrays and with primitive arrays.null, 0 is returned.\n * ArrayUtils.getLength(null) = 0\n * ArrayUtils.getLength([]) = 0\n * ArrayUtils.getLength([null]) = 1\n * ArrayUtils.getLength([true, false]) = 2\n * ArrayUtils.getLength([1, 2, 3]) = 3\n * ArrayUtils.getLength([\"a\", \"b\", \"c\"]) = 3\n *
\n *\n * @param array the array to retrieve the length from, may be null\n * @return The length of the array, or 0 if the array is null\n * @throws IllegalArgumentException if the object arguement is not an array.\n * @since 2.1\n */\n public static int getLength(final Object array) {\n if (array == null) {\n return 0;\n }\n return Array.getLength(array);\n }\n\n /**\n * null\n * @param array2 the second array, must not be null\n * @return true if type of arrays matches\n * @throws IllegalArgumentException if either array is null\n */\n public static boolean isSameType(final Object array1, final Object array2) {\n if (array1 == null || array2 == null) {\n throw new IllegalArgumentException(\"The Array must not be null\");\n }\n return array1.getClass().getName().equals(array2.getClass().getName());\n }\n // Reverse\n //-----------------------------------------------------------------------\n\n /**\n * null input array.null\n */\n public static void reverse(final Object[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n Object tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final long[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n long tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final int[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n int tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final short[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n short tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final char[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n char tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final byte[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n byte tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final double[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n double tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final float[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n float tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n /**\n * null input array.null\n */\n public static void reverse(final boolean[] array) {\n if (array == null) {\n return;\n }\n int i = 0;\n int j = array.length - 1;\n boolean tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n // IndexOf search\n // ----------------------------------------------------------------------\n // Object IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param objectToFind the object to find, may be null\n * @return the index of the object within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final Object[] array, final Object objectToFind) {\n return ArrayUtils.indexOf(array, objectToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param objectToFind the object to find, may be null\n * @param startIndex the index to start searching at\n * @return the index of the object within the array starting at the index,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final Object[] array, final Object objectToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n if (objectToFind == null) {\n for (int i = startIndex; i < array.length; i++) {\n if (array[i] == null) {\n return i;\n }\n }\n } else if (array.getClass().getComponentType().isInstance(objectToFind)) {\n for (int i = startIndex; i < array.length; i++) {\n if (objectToFind.equals(array[i])) {\n return i;\n }\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param objectToFind the object to find, may be null\n * @return the last index of the object within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final Object[] array, final Object objectToFind) {\n return ArrayUtils.lastIndexOf(array, objectToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than\n * the array length will search from the end of the array.null\n * @param objectToFind the object to find, may be null\n * @param startIndex the start index to travers backwards from\n * @return the last index of the object within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final Object[] array, final Object objectToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n if (objectToFind == null) {\n for (int i = startIndex; i >= 0; i--) {\n if (array[i] == null) {\n return i;\n }\n }\n } else if (array.getClass().getComponentType().isInstance(objectToFind)) {\n for (int i = startIndex; i >= 0; i--) {\n if (objectToFind.equals(array[i])) {\n return i;\n }\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final Object[] array, final Object objectToFind) {\n return ArrayUtils.indexOf(array, objectToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // long IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final long[] array, final long valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final long[] array, final long valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final long[] array, final long valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final long[] array, final long valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final long[] array, final long valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // int IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final int[] array, final int valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final int[] array, final int valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final int[] array, final int valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final int[] array, final int valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final int[] array, final int valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // short IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final short[] array, final short valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final short[] array, final short valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final short[] array, final short valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final short[] array, final short valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final short[] array, final short valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // char IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n * @since 2.1\n */\n public static int indexOf(final char[] array, final char valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n * @since 2.1\n */\n public static int indexOf(final char[] array, final char valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n * @since 2.1\n */\n public static int lastIndexOf(final char[] array, final char valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n * @since 2.1\n */\n public static int lastIndexOf(final char[] array, final char valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n * @since 2.1\n */\n public static boolean contains(final char[] array, final char valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // byte IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final byte[] array, final byte valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final byte[] array, final byte valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final byte[] array, final byte valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final byte[] array, final byte valueToFind, int startIndex) {\n if (array == null) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final byte[] array, final byte valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // double IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final double[] array, final double valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @param tolerance tolerance of the search\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final double[] array, final double valueToFind, final double tolerance) {\n return ArrayUtils.indexOf(array, valueToFind, 0, tolerance);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final double[] array, final double valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @param tolerance tolerance of the search\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final double[] array, final double valueToFind, int startIndex, final double tolerance) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n double min = valueToFind - tolerance;\n double max = valueToFind + tolerance;\n for (int i = startIndex; i < array.length; i++) {\n if (array[i] >= min && array[i] <= max) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final double[] array, final double valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @param tolerance tolerance of the search\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final double[] array, final double valueToFind, final double tolerance) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE, tolerance);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @param tolerance search for value within plus/minus this amount\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex, final double tolerance) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n double min = valueToFind - tolerance;\n double max = valueToFind + tolerance;\n for (int i = startIndex; i >= 0; i--) {\n if (array[i] >= min && array[i] <= max) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final double[] array, final double valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array\n * is passed in.-1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final float[] array, final float valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final float[] array, final float valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final float[] array, final float valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than the\n * array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final float[] array, final float valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final float[] array, final float valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // boolean IndexOf\n //-----------------------------------------------------------------------\n\n /**\n * -1) for a null input array.null\n * @param valueToFind the value to find\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int indexOf(final boolean[] array, final boolean valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind, 0);\n }\n\n /**\n * -1) for a null input array.-1).null\n * @param valueToFind the value to find\n * @param startIndex the index to start searching at\n * @return the index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null\n * array input\n */\n public static int indexOf(final boolean[] array, final boolean valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n startIndex = 0;\n }\n for (int i = startIndex; i < array.length; i++) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * -1) if\n * null array input.null\n * @param valueToFind the object to find\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final boolean[] array, final boolean valueToFind) {\n return ArrayUtils.lastIndexOf(array, valueToFind, Integer.MAX_VALUE);\n }\n\n /**\n * -1) for a null input array.-1). A startIndex larger than\n * the array length will search from the end of the array.null\n * @param valueToFind the value to find\n * @param startIndex the start index to travers backwards from\n * @return the last index of the value within the array,\n * {@link #INDEX_NOT_FOUND} (-1) if not found or null array input\n */\n public static int lastIndexOf(final boolean[] array, final boolean valueToFind, int startIndex) {\n if (ArrayUtils.isEmpty(array)) {\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n if (startIndex < 0) {\n return ArrayUtils.INDEX_NOT_FOUND;\n } else if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n for (int i = startIndex; i >= 0; i--) {\n if (valueToFind == array[i]) {\n return i;\n }\n }\n return ArrayUtils.INDEX_NOT_FOUND;\n }\n\n /**\n * false if a null array is passed in.true if the array contains the object\n */\n public static boolean contains(final boolean[] array, final boolean valueToFind) {\n return ArrayUtils.indexOf(array, valueToFind) != ArrayUtils.INDEX_NOT_FOUND;\n }\n // Primitive/Object array converters\n // ----------------------------------------------------------------------\n // Character array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Character array, may be null\n * @return a char array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static char[] toPrimitive(final Character[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_CHAR_ARRAY;\n }\n final char[] result = new char[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].charValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Character array, may be null\n * @param valueForNull the value to insert if null found\n * @return a char array, null if null array input\n */\n public static char[] toPrimitive(final Character[] array, final char valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_CHAR_ARRAY;\n }\n final char[] result = new char[array.length];\n for (int i = 0; i < array.length; i++) {\n Character b = array[i];\n result[i] = b == null ? valueForNull : b.charValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.char array\n * @return a Character array, null if null array input\n */\n public static Character[] toObject(final char[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY;\n }\n final Character[] result = new Character[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Character(array[i]);\n }\n return result;\n }\n // Long array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Long array, may be null\n * @return a long array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static long[] toPrimitive(final Long[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_LONG_ARRAY;\n }\n final long[] result = new long[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].longValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Long array, may be null\n * @param valueForNull the value to insert if null found\n * @return a long array, null if null array input\n */\n public static long[] toPrimitive(final Long[] array, final long valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_LONG_ARRAY;\n }\n final long[] result = new long[array.length];\n for (int i = 0; i < array.length; i++) {\n Long b = array[i];\n result[i] = b == null ? valueForNull : b.longValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.long array\n * @return a Long array, null if null array input\n */\n public static Long[] toObject(final long[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_LONG_OBJECT_ARRAY;\n }\n final Long[] result = new Long[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Long(array[i]);\n }\n return result;\n }\n // Int array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Integer array, may be null\n * @return an int array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static int[] toPrimitive(final Integer[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_INT_ARRAY;\n }\n final int[] result = new int[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].intValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Integer array, may be null\n * @param valueForNull the value to insert if null found\n * @return an int array, null if null array input\n */\n public static int[] toPrimitive(final Integer[] array, final int valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_INT_ARRAY;\n }\n final int[] result = new int[array.length];\n for (int i = 0; i < array.length; i++) {\n Integer b = array[i];\n result[i] = b == null ? valueForNull : b.intValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.int array\n * @return an Integer array, null if null array input\n */\n public static Integer[] toObject(final int[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY;\n }\n final Integer[] result = new Integer[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Integer(array[i]);\n }\n return result;\n }\n // Short array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Short array, may be null\n * @return a byte array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static short[] toPrimitive(final Short[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_SHORT_ARRAY;\n }\n final short[] result = new short[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].shortValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Short array, may be null\n * @param valueForNull the value to insert if null found\n * @return a byte array, null if null array input\n */\n public static short[] toPrimitive(final Short[] array, final short valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_SHORT_ARRAY;\n }\n final short[] result = new short[array.length];\n for (int i = 0; i < array.length; i++) {\n Short b = array[i];\n result[i] = b == null ? valueForNull : b.shortValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.short array\n * @return a Short array, null if null array input\n */\n public static Short[] toObject(final short[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY;\n }\n final Short[] result = new Short[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Short(array[i]);\n }\n return result;\n }\n // Byte array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Byte array, may be null\n * @return a byte array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static byte[] toPrimitive(final Byte[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BYTE_ARRAY;\n }\n final byte[] result = new byte[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].byteValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Byte array, may be null\n * @param valueForNull the value to insert if null found\n * @return a byte array, null if null array input\n */\n public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BYTE_ARRAY;\n }\n final byte[] result = new byte[array.length];\n for (int i = 0; i < array.length; i++) {\n Byte b = array[i];\n result[i] = b == null ? valueForNull : b.byteValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.byte array\n * @return a Byte array, null if null array input\n */\n public static Byte[] toObject(final byte[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY;\n }\n final Byte[] result = new Byte[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Byte(array[i]);\n }\n return result;\n }\n // Double array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Double array, may be null\n * @return a double array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static double[] toPrimitive(final Double[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_DOUBLE_ARRAY;\n }\n final double[] result = new double[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].doubleValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Double array, may be null\n * @param valueForNull the value to insert if null found\n * @return a double array, null if null array input\n */\n public static double[] toPrimitive(final Double[] array, final double valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_DOUBLE_ARRAY;\n }\n final double[] result = new double[array.length];\n for (int i = 0; i < array.length; i++) {\n Double b = array[i];\n result[i] = b == null ? valueForNull : b.doubleValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.double array\n * @return a Double array, null if null array input\n */\n public static Double[] toObject(final double[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY;\n }\n final Double[] result = new Double[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Double(array[i]);\n }\n return result;\n }\n // Float array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Float array, may be null\n * @return a float array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static float[] toPrimitive(final Float[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_FLOAT_ARRAY;\n }\n final float[] result = new float[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].floatValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Float array, may be null\n * @param valueForNull the value to insert if null found\n * @return a float array, null if null array input\n */\n public static float[] toPrimitive(final Float[] array, final float valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_FLOAT_ARRAY;\n }\n final float[] result = new float[array.length];\n for (int i = 0; i < array.length; i++) {\n Float b = array[i];\n result[i] = b == null ? valueForNull : b.floatValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.float array\n * @return a Float array, null if null array input\n */\n public static Float[] toObject(final float[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY;\n }\n final Float[] result = new Float[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = new Float(array[i]);\n }\n return result;\n }\n // Boolean array converters\n // ----------------------------------------------------------------------\n\n /**\n * null for a null input array.Boolean array, may be null\n * @return a boolean array, null if null array input\n * @throws NullPointerException if array content is null\n */\n public static boolean[] toPrimitive(final Boolean[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BOOLEAN_ARRAY;\n }\n final boolean[] result = new boolean[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i].booleanValue();\n }\n return result;\n }\n\n /**\n * null.null for a null input array.Boolean array, may be null\n * @param valueForNull the value to insert if null found\n * @return a boolean array, null if null array input\n */\n public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BOOLEAN_ARRAY;\n }\n final boolean[] result = new boolean[array.length];\n for (int i = 0; i < array.length; i++) {\n Boolean b = array[i];\n result[i] = b == null ? valueForNull : b.booleanValue();\n }\n return result;\n }\n\n /**\n * null for a null input array.boolean array\n * @return a Boolean array, null if null array input\n */\n public static Boolean[] toObject(final boolean[] array) {\n if (array == null) {\n return null;\n } else if (array.length == 0) {\n return ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY;\n }\n final Boolean[] result = new Boolean[array.length];\n for (int i = 0; i < array.length; i++) {\n result[i] = array[i] ? Boolean.TRUE : Boolean.FALSE;\n }\n return result;\n }\n // ----------------------------------------------------------------------\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final Object[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final long[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final int[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final short[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final char[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final byte[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final double[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final float[] array) {\n return array == null || array.length == 0;\n }\n\n /**\n * null.true if the array is empty or null\n * @since 2.1\n */\n public static boolean isEmpty(final boolean[] array) {\n return array == null || array.length == 0;\n }\n // ----------------------------------------------------------------------\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final Object[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final long[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final int[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final short[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final char[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final byte[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final double[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final float[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * null.true if the array is not empty or not null\n * @since 2.5\n */\n public static boolean isNotEmpty(final boolean[] array) {\n return array != null && array.length != 0;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(null, null) = null\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n * ArrayUtils.addAll([null], [null]) = [null, null]\n * ArrayUtils.addAll([\"a\", \"b\", \"c\"], [\"1\", \"2\", \"3\"]) = [\"a\", \"b\", \"c\", \"1\", \"2\", \"3\"]\n *
\n *\n * @param array1 the first array whose elements are added to the new array, may be null\n * @param array2 the second array whose elements are added to the new array, may be null\n * @return The new array, null if both arrays are null.\n * The type of the new array is the type of the first array,\n * unless the first array is null, in which case the type is the same as the second array.\n * @since 2.1\n * @throws IllegalArgumentException if the array types are incompatible\n */\n public static Object[] addAll(final Object[] array1, final Object[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n Object[] joinedArray = (Object[]) Array.newInstance(array1.getClass().getComponentType(), array1.length + array2.length);\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n try {\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n } catch (ArrayStoreException ase) {\n // Check if problem was due to incompatible types\n /*\n * We do this here, rather than before the copy because:\n * - it would be a wasted check most of the time\n * - safer, in case check turns out to be too strict\n */\n final Class> type1 = array1.getClass().getComponentType();\n final Class> type2 = array2.getClass().getComponentType();\n if (!type1.isAssignableFrom(type2)) {\n throw new IllegalArgumentException(\"Cannot store \" + type2.getName() + \" in an array of \" + type1.getName());\n }\n throw ase; // No, so rethrow original\n }\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new boolean[] array.\n * @since 2.1\n */\n public static boolean[] addAll(final boolean[] array1, final boolean[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n boolean[] joinedArray = new boolean[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new char[] array.\n * @since 2.1\n */\n public static char[] addAll(final char[] array1, final char[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n char[] joinedArray = new char[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new byte[] array.\n * @since 2.1\n */\n public static byte[] addAll(final byte[] array1, final byte[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n byte[] joinedArray = new byte[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new short[] array.\n * @since 2.1\n */\n public static short[] addAll(final short[] array1, final short[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n short[] joinedArray = new short[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new int[] array.\n * @since 2.1\n */\n public static int[] addAll(final int[] array1, final int[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n int[] joinedArray = new int[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new long[] array.\n * @since 2.1\n */\n public static long[] addAll(final long[] array1, final long[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n long[] joinedArray = new long[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new float[] array.\n * @since 2.1\n */\n public static float[] addAll(final float[] array1, final float[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n float[] joinedArray = new float[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new double[] array.\n * @since 2.1\n */\n public static double[] addAll(final double[] array1, final double[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n double[] joinedArray = new double[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n /**\n * array1 followed\n * by all of the elements array2. When an array is returned, it is always\n * a new array.\n * ArrayUtils.addAll(array1, null) = cloned copy of array1\n * ArrayUtils.addAll(null, array2) = cloned copy of array2\n * ArrayUtils.addAll([], []) = []\n *
\n *\n * @param array1 the first array whose elements are added to the new array.\n * @param array2 the second array whose elements are added to the new array.\n * @return The new String[] array.\n * @since 2.1\n */\n public static String[] addAll(final String[] array1, final String[] array2) {\n if (array1 == null) {\n return ArrayUtils.clone(array2);\n } else if (array2 == null) {\n return ArrayUtils.clone(array1);\n }\n String[] joinedArray = new String[array1.length + array2.length];\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n return joinedArray;\n }\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element, unless the element itself is null,\n * in which case the return type is Object[]\n * ArrayUtils.add(null, null) = [null]\n * ArrayUtils.add(null, \"a\") = [\"a\"]\n * ArrayUtils.add([\"a\"], null) = [\"a\", null]\n * ArrayUtils.add([\"a\"], \"b\") = [\"a\", \"b\"]\n * ArrayUtils.add([\"a\", \"b\"], \"c\") = [\"a\", \"b\", \"c\"]\n *
\n *\n * @param array the array to \"add\" the element to, may be null\n * @param element the object to add, may be null\n * @return A new array containing the existing elements plus the new element\n * The returned array type will be that of the input array (unless null),\n * in which case it will have the same type as the element.\n * @since 2.1\n */\n public static null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, true) = [true]\n * ArrayUtils.add([true], false) = [true, false]\n * ArrayUtils.add([true, false], true) = [true, false, true]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static boolean[] add(final boolean[] array, final boolean element) {\n boolean[] newArray = (boolean[]) ArrayUtils.copyArrayGrow1(array, Boolean.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static byte[] add(final byte[] array, final byte element) {\n byte[] newArray = (byte[]) ArrayUtils.copyArrayGrow1(array, Byte.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, '0') = ['0']\n * ArrayUtils.add(['1'], '0') = ['1', '0']\n * ArrayUtils.add(['1', '0'], '1') = ['1', '0', '1']\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static char[] add(final char[] array, final char element) {\n char[] newArray = (char[]) ArrayUtils.copyArrayGrow1(array, Character.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static double[] add(final double[] array, final double element) {\n double[] newArray = (double[]) ArrayUtils.copyArrayGrow1(array, Double.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static float[] add(final float[] array, final float element) {\n float[] newArray = (float[]) ArrayUtils.copyArrayGrow1(array, Float.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static int[] add(final int[] array, final int element) {\n int[] newArray = (int[]) ArrayUtils.copyArrayGrow1(array, Integer.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static long[] add(final long[] array, final long element) {\n long[] newArray = (long[]) ArrayUtils.copyArrayGrow1(array, Long.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0) = [0]\n * ArrayUtils.add([1], 0) = [1, 0]\n * ArrayUtils.add([1, 0], 1) = [1, 0, 1]\n *
\n *\n * @param array the array to copy and add the element to, may be null\n * @param element the object to add at the last index of the new array\n * @return A new array containing the existing elements plus the new element\n * @since 2.1\n */\n public static short[] add(final short[] array, final short element) {\n short[] newArray = (short[]) ArrayUtils.copyArrayGrow1(array, Short.TYPE);\n newArray[newArray.length - 1] = element;\n return newArray;\n }\n\n /**\n * Returns a copy of the given array of size 1 greater than the argument.\n * The last value of the array is left to the default value.\n *\n * @param array The array to copy, must not be null.\n * @param newArrayComponentType If array is null, create a\n * size 1 array of this type.\n * @return A new copy of the array of size 1 greater than the input.\n */\n private static Object copyArrayGrow1(final Object array, final Class> newArrayComponentType) {\n if (array != null) {\n int arrayLength = Array.getLength(array);\n Object newArray = Array.newInstance(array.getClass().getComponentType(), arrayLength + 1);\n System.arraycopy(array, 0, newArray, 0, arrayLength);\n return newArray;\n }\n return Array.newInstance(newArrayComponentType, 1);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0, null) = [null]\n * ArrayUtils.add(null, 0, \"a\") = [\"a\"]\n * ArrayUtils.add([\"a\"], 1, null) = [\"a\", null]\n * ArrayUtils.add([\"a\"], 1, \"b\") = [\"a\", \"b\"]\n * ArrayUtils.add([\"a\", \"b\"], 3, \"c\") = [\"a\", \"b\", \"c\"]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index > array.length).\n */\n public static Object[] add(final Object[] array, final int index, final Object element) {\n Class> clss = null;\n if (array != null) {\n clss = array.getClass().getComponentType();\n } else if (element != null) {\n clss = element.getClass();\n } else {\n return new Object[] { null };\n }\n return (Object[]) ArrayUtils.add(array, index, element, clss);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0, true) = [true]\n * ArrayUtils.add([true], 0, false) = [false, true]\n * ArrayUtils.add([false], 1, true) = [false, true]\n * ArrayUtils.add([true, false], 1, true) = [true, true, false]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static boolean[] add(final boolean[] array, final int index, final boolean element) {\n Boolean booElement = element ? Boolean.TRUE : Boolean.FALSE;\n return (boolean[]) ArrayUtils.add(array, index, booElement, Boolean.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add(null, 0, 'a') = ['a']\n * ArrayUtils.add(['a'], 0, 'b') = ['b', 'a']\n * ArrayUtils.add(['a', 'b'], 0, 'c') = ['c', 'a', 'b']\n * ArrayUtils.add(['a', 'b'], 1, 'k') = ['a', 'k', 'b']\n * ArrayUtils.add(['a', 'b', 'c'], 1, 't') = ['a', 't', 'b', 'c']\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static char[] add(final char[] array, final int index, final char element) {\n return (char[]) ArrayUtils.add(array, index, new Character(element), Character.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1], 0, 2) = [2, 1]\n * ArrayUtils.add([2, 6], 2, 3) = [2, 6, 3]\n * ArrayUtils.add([2, 6], 0, 1) = [1, 2, 6]\n * ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static byte[] add(final byte[] array, final int index, final byte element) {\n return (byte[]) ArrayUtils.add(array, index, new Byte(element), Byte.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1], 0, 2) = [2, 1]\n * ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10]\n * ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6]\n * ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static short[] add(final short[] array, final int index, final short element) {\n return (short[]) ArrayUtils.add(array, index, new Short(element), Short.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1], 0, 2) = [2, 1]\n * ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10]\n * ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6]\n * ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static int[] add(final int[] array, final int index, final int element) {\n return (int[]) ArrayUtils.add(array, index, new Integer(element), Integer.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1L], 0, 2L) = [2L, 1L]\n * ArrayUtils.add([2L, 6L], 2, 10L) = [2L, 6L, 10L]\n * ArrayUtils.add([2L, 6L], 0, -4L) = [-4L, 2L, 6L]\n * ArrayUtils.add([2L, 6L, 3L], 2, 1L) = [2L, 6L, 1L, 3L]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static long[] add(final long[] array, final int index, final long element) {\n return (long[]) ArrayUtils.add(array, index, new Long(element), Long.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1.1f], 0, 2.2f) = [2.2f, 1.1f]\n * ArrayUtils.add([2.3f, 6.4f], 2, 10.5f) = [2.3f, 6.4f, 10.5f]\n * ArrayUtils.add([2.6f, 6.7f], 0, -4.8f) = [-4.8f, 2.6f, 6.7f]\n * ArrayUtils.add([2.9f, 6.0f, 0.3f], 2, 1.0f) = [2.9f, 6.0f, 1.0f, 0.3f]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static float[] add(final float[] array, final int index, final float element) {\n return (float[]) ArrayUtils.add(array, index, new Float(element), Float.TYPE);\n }\n\n /**\n * null, a new one element array is returned\n * whose component type is the same as the element.\n * ArrayUtils.add([1.1], 0, 2.2) = [2.2, 1.1]\n * ArrayUtils.add([2.3, 6.4], 2, 10.5) = [2.3, 6.4, 10.5]\n * ArrayUtils.add([2.6, 6.7], 0, -4.8) = [-4.8, 2.6, 6.7]\n * ArrayUtils.add([2.9, 6.0, 0.3], 2, 1.0) = [2.9, 6.0, 1.0, 0.3]\n *
\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @return A new array containing the existing elements and the new element\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index > array.length).\n */\n public static double[] add(final double[] array, final int index, final double element) {\n return (double[]) ArrayUtils.add(array, index, new Double(element), Double.TYPE);\n }\n\n /**\n * Underlying implementation of add(array, index, element) methods.\n * The last parameter is the class, which may not equal element.getClass\n * for primitives.\n *\n * @param array the array to add the element to, may be null\n * @param index the position of the new object\n * @param element the object to add\n * @param clss the type of the element being added\n * @return A new array containing the existing elements and the new element\n */\n private static Object add(final Object array, final int index, final Object element, final Class> clss) {\n if (array == null) {\n if (index != 0) {\n throw new IndexOutOfBoundsException(\"Index: \" + index + \", Length: 0\");\n }\n Object joinedArray = Array.newInstance(clss, 1);\n Array.set(joinedArray, 0, element);\n return joinedArray;\n }\n int length = Array.getLength(array);\n if (index > length || index < 0) {\n throw new IndexOutOfBoundsException(\"Index: \" + index + \", Length: \" + length);\n }\n Object result = Array.newInstance(clss, length + 1);\n System.arraycopy(array, 0, result, 0, index);\n Array.set(result, index, element);\n if (index < length) {\n System.arraycopy(array, index, result, index + 1, length - index);\n }\n return result;\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([\"a\"], 0) = []\n * ArrayUtils.remove([\"a\", \"b\"], 0) = [\"b\"]\n * ArrayUtils.remove([\"a\", \"b\"], 1) = [\"a\"]\n * ArrayUtils.remove([\"a\", \"b\", \"c\"], 1) = [\"a\", \"c\"]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static Object[] remove(final Object[] array, final int index) {\n return (Object[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, \"a\") = null\n * ArrayUtils.removeElement([], \"a\") = []\n * ArrayUtils.removeElement([\"a\"], \"b\") = [\"a\"]\n * ArrayUtils.removeElement([\"a\", \"b\"], \"a\") = [\"b\"]\n * ArrayUtils.removeElement([\"a\", \"b\", \"a\"], \"a\") = [\"b\", \"a\"]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static Object[] removeElement(final Object[] array, final Object element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([true], 0) = []\n * ArrayUtils.remove([true, false], 0) = [false]\n * ArrayUtils.remove([true, false], 1) = [true]\n * ArrayUtils.remove([true, true, false], 1) = [true, false]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static boolean[] remove(final boolean[] array, final int index) {\n return (boolean[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, true) = null\n * ArrayUtils.removeElement([], true) = []\n * ArrayUtils.removeElement([true], false) = [true]\n * ArrayUtils.removeElement([true, false], false) = [true]\n * ArrayUtils.removeElement([true, false, true], true) = [false, true]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static boolean[] removeElement(final boolean[] array, final boolean element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1], 0) = []\n * ArrayUtils.remove([1, 0], 0) = [0]\n * ArrayUtils.remove([1, 0], 1) = [1]\n * ArrayUtils.remove([1, 0, 1], 1) = [1, 1]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static byte[] remove(final byte[] array, final int index) {\n return (byte[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1) = null\n * ArrayUtils.removeElement([], 1) = []\n * ArrayUtils.removeElement([1], 0) = [1]\n * ArrayUtils.removeElement([1, 0], 0) = [1]\n * ArrayUtils.removeElement([1, 0, 1], 1) = [0, 1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static byte[] removeElement(final byte[] array, final byte element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove(['a'], 0) = []\n * ArrayUtils.remove(['a', 'b'], 0) = ['b']\n * ArrayUtils.remove(['a', 'b'], 1) = ['a']\n * ArrayUtils.remove(['a', 'b', 'c'], 1) = ['a', 'c']\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static char[] remove(final char[] array, final int index) {\n return (char[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 'a') = null\n * ArrayUtils.removeElement([], 'a') = []\n * ArrayUtils.removeElement(['a'], 'b') = ['a']\n * ArrayUtils.removeElement(['a', 'b'], 'a') = ['b']\n * ArrayUtils.removeElement(['a', 'b', 'a'], 'a') = ['b', 'a']\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static char[] removeElement(final char[] array, final char element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1.1], 0) = []\n * ArrayUtils.remove([2.5, 6.0], 0) = [6.0]\n * ArrayUtils.remove([2.5, 6.0], 1) = [2.5]\n * ArrayUtils.remove([2.5, 6.0, 3.8], 1) = [2.5, 3.8]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static double[] remove(final double[] array, final int index) {\n return (double[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1.1) = null\n * ArrayUtils.removeElement([], 1.1) = []\n * ArrayUtils.removeElement([1.1], 1.2) = [1.1]\n * ArrayUtils.removeElement([1.1, 2.3], 1.1) = [2.3]\n * ArrayUtils.removeElement([1.1, 2.3, 1.1], 1.1) = [2.3, 1.1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static double[] removeElement(final double[] array, final double element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1.1], 0) = []\n * ArrayUtils.remove([2.5, 6.0], 0) = [6.0]\n * ArrayUtils.remove([2.5, 6.0], 1) = [2.5]\n * ArrayUtils.remove([2.5, 6.0, 3.8], 1) = [2.5, 3.8]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static float[] remove(final float[] array, final int index) {\n return (float[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1.1) = null\n * ArrayUtils.removeElement([], 1.1) = []\n * ArrayUtils.removeElement([1.1], 1.2) = [1.1]\n * ArrayUtils.removeElement([1.1, 2.3], 1.1) = [2.3]\n * ArrayUtils.removeElement([1.1, 2.3, 1.1], 1.1) = [2.3, 1.1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static float[] removeElement(final float[] array, final float element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1], 0) = []\n * ArrayUtils.remove([2, 6], 0) = [6]\n * ArrayUtils.remove([2, 6], 1) = [2]\n * ArrayUtils.remove([2, 6, 3], 1) = [2, 3]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static int[] remove(final int[] array, final int index) {\n return (int[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1) = null\n * ArrayUtils.removeElement([], 1) = []\n * ArrayUtils.removeElement([1], 2) = [1]\n * ArrayUtils.removeElement([1, 3], 1) = [3]\n * ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static int[] removeElement(final int[] array, final int element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1], 0) = []\n * ArrayUtils.remove([2, 6], 0) = [6]\n * ArrayUtils.remove([2, 6], 1) = [2]\n * ArrayUtils.remove([2, 6, 3], 1) = [2, 3]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static long[] remove(final long[] array, final int index) {\n return (long[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1) = null\n * ArrayUtils.removeElement([], 1) = []\n * ArrayUtils.removeElement([1], 2) = [1]\n * ArrayUtils.removeElement([1, 3], 1) = [3]\n * ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static long[] removeElement(final long[] array, final long element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.\n * ArrayUtils.remove([1], 0) = []\n * ArrayUtils.remove([2, 6], 0) = [6]\n * ArrayUtils.remove([2, 6], 1) = [2]\n * ArrayUtils.remove([2, 6, 3], 1) = [2, 3]\n *
\n *\n * @param array the array to remove the element from, may not be null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n public static short[] remove(final short[] array, final int index) {\n return (short[]) ArrayUtils.remove((Object) array, index);\n }\n\n /**\n * \n * ArrayUtils.removeElement(null, 1) = null\n * ArrayUtils.removeElement([], 1) = []\n * ArrayUtils.removeElement([1], 2) = [1]\n * ArrayUtils.removeElement([1, 3], 1) = [3]\n * ArrayUtils.removeElement([1, 3, 1], 1) = [3, 1]\n *
\n *\n * @param array the array to remove the element from, may be null\n * @param element the element to be removed\n * @return A new array containing the existing elements except the first\n * occurrence of the specified element.\n * @since 2.1\n */\n public static short[] removeElement(final short[] array, final short element) {\n int index = ArrayUtils.indexOf(array, element);\n if (index == ArrayUtils.INDEX_NOT_FOUND) {\n return ArrayUtils.clone(array);\n }\n return ArrayUtils.remove(array, index);\n }\n\n /**\n * null, an IndexOutOfBoundsException\n * will be thrown, because in that case no valid index can be specified.null\n * @param index the position of the element to be removed\n * @return A new array containing the existing elements except the element\n * at the specified position.\n * @throws IndexOutOfBoundsException if the index is out of range\n * (index < 0 || index >= array.length), or if the array is null.\n * @since 2.1\n */\n private static Object remove(final Object array, final int index) {\n int length = ArrayUtils.getLength(array);\n if (index < 0 || index >= length) {\n throw new IndexOutOfBoundsException(\"Index: \" + index + \", Length: \" + length);\n }\n Object result = Array.newInstance(array.getClass().getComponentType(), length - 1);\n System.arraycopy(array, 0, result, 0, index);\n if (index < length - 1) {\n System.arraycopy(array, index + 1, result, index, length - index - 1);\n }\n return result;\n }\n\n /**删除数组中空元素*/\n public static Object[] clearNull(final Object[] arr) {\n ArrayList