public final class ArrayUtils extends Object
Modifier | Constructor and Description |
---|---|
private |
ArrayUtils()
Hidden Utility constructor.
|
Modifier and Type | Method and Description |
---|---|
static long |
max(long[] longs)
Get the maximum element in an array of longs.
|
static void |
scale(long[] longs,
double scale)
Modify an array by multiplying each element by a constant scaling factor.
|
static Double |
sum(Double[] doubles)
Get the sum of an array of doubles.
|
static Integer |
sum(Integer[] integers)
Get the sum of an array of integers.
|
static List<Double> |
toArrayListDouble(String str)
Create a new ArrayList from a comma separated list of ints encoded as string values.
|
static List<Integer> |
toArrayListInteger(String str)
Create a new ArrayList from a comma separated list of integers encoded as string values.
|
static Collection<String> |
toCollectionStrings(String str)
Split a string into a collection of strings, ignoring whitespace around each string.
|
static Double[] |
toDoubleArray(String str)
Given a comma separated string containing double values as strings convert them to an
array of Doubles.
|
static Double[] |
toDoubleArray(String[] arr)
Given an array containing double values as string convert them to Doubles.
|
static Integer[] |
toIntegerArray(String str)
Given a comma separated string containing integer values as strings convert them to an
array of integers.
|
static Integer[] |
toIntegerArray(String[] arr)
Given an array containing integer values as string convert them to integers.
|
static String |
toString(Object[] objects)
Create a csv string for an array of Objects.
|
static String |
toString(Object[] objects,
Format fmt)
Create a csv string for an array of Objects.
|
static String[] |
toStringArray(String str)
Split a string into an array strings, ignoring whitespace around each string.
|
static String[] |
toStringArray(String str,
char token)
Split a string into an array strings,ignoring whitespace around each string.
|
static String[] |
toStringArray(String str,
Pattern token)
Split a string into an array strings,ignoring whitespace around each string.
|
public static long max(long[] longs)
longs
- the array to search.public static Double sum(Double[] doubles)
doubles
- the array to sum.public static Integer sum(Integer[] integers)
integers
- the array to sum.public static void scale(long[] longs, double scale)
longs
- the array to scale.scale
- the scaling factorpublic static Double[] toDoubleArray(String[] arr)
arr
- the String[] to be converted.public static Double[] toDoubleArray(String str)
str
- the string containing comma separated double values.public static List<Double> toArrayListDouble(String str)
str
- a comma separated list of double valuespublic static Integer[] toIntegerArray(String[] arr)
arr
- the String[] to be converted.public static Integer[] toIntegerArray(String str)
str
- the string containing comma separated double values.public static List<Integer> toArrayListInteger(String str)
str
- a comma separated list of integer valuespublic static String[] toStringArray(String str, Pattern token)
str
- the string to splittoken
- the (char) token used to split the string.public static String[] toStringArray(String str, char token)
str
- the string to splittoken
- the (char) token used to split the string.public static String[] toStringArray(String str)
str
- the string to splitpublic static Collection<String> toCollectionStrings(String str)
str
- the string to splitpublic static String toString(Object[] objects)
objects
- the array of objects.Copyright © 2015 University of Glasgow. All rights reserved.