01 30 seconds of java8
Array
chunk
public static int[][] chunk(int[] numbers, int size) {
return IntStream.iterate(0, i -> i + size)
.limit((long) Math.ceil((double) numbers.length / size))
.mapToObj(cur -> Arrays.copyOfRange(numbers, cur, Math.min(cur + size, numbers.length)))
.toArray(int[][]::new);
}concat
public static <T> T[] concat(T[] first, T[] second) {
return Stream.concat(Stream.of(first), Stream.of(second))
.toArray(i -> (T[]) Arrays.copyOf(new Object[0], i, first.getClass()));
}countOccurrences
deepFlatten
difference
distinctValuesOfArray
everyNth
indexOf
lastIndexOf
filterNonUnique
initializeArrayWithRange
initializeArrayWithValues
intersection
nthElement
pick
sample
shuffle
sampleSize
similarity
symmetricDifference
union
without
Maths
average
isEven
generateRandomInt
String
anagrams
isNumeric
reverseString
splitLines
stringToIntegers
Enum
getEnumMap
IO
readFileAsString
getCurrentWorkingDirectoryPath
stackTraceAsString
最后更新于