Java Utililty Methods Array Element Get

List of utility methods to do Array Element Get

Description

The list of methods to do Array Element Get are organized into topic(s).

Method

String[]getArgsOption(String[] args, String option)
To get values for an given option from command line arguments.
if (args == null || args.length <= 0) {
    return null;
String optionChar = "-";
String optionString = optionChar + option;
ArrayList<String> values = new ArrayList<String>();
int currentArgsIndex = -1;
int totalArgs = args.length;
...
Object[]getArrayNoNull(Object[] array)
get Array No Null
if (array != null && array.length > 0) {
    List<Object> result = new ArrayList<>();
    for (Object obj : array) {
        if (!isNull(obj))
            result.add(obj);
    return result.toArray();
return null;
StringgetArrayPreview(final Object[] array, final int previewSize)
Generates a string that enumerates just the first elements of an array (a preview).
return getCollectionPreview(Arrays.asList(array), previewSize);
byte[][]getArrays(byte[] inputArray, int arraySize, boolean zeroPad)
Convert a large byte array into multiple smaller byte arrays, with the output size determined by the caller
byte[][] tdba = new byte[(int) Math.ceil(inputArray.length / (double) arraySize)][arraySize];
int start = 0;
for (int i = 0; i < tdba.length; i++) {
    if (start + arraySize > inputArray.length) {
        byte[] lastArray;
        if (zeroPad) {
            lastArray = new byte[arraySize];
            Arrays.fill(lastArray, (byte) 0x00);
...
T[]getArraySubset(T[] array, int start, int end)
get Array Subset
return Arrays.copyOfRange(array, start, end);
intgetFrequentElement(int[] bcp)
get Frequent Element
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
ArrayList<Integer> count = new ArrayList<Integer>();
ArrayList<Integer> uniId = new ArrayList<Integer>();
int id = 0;
for (int col = 0; col < bcp.length; col++) {
    int no = 0;
    if (!map.containsKey(bcp[col])) {
        map.put(bcp[col], id++);
...
intgetFrequentElement(int[] bcp)
get Frequent Element
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
ArrayList<Integer> count = new ArrayList<Integer>();
ArrayList<Integer> uniId = new ArrayList<Integer>();
int id = 0;
for (int col = 0; col < bcp.length; col++) {
    int no = 0;
    if (!map.containsKey(bcp[col])) {
        map.put(bcp[col], id++);
...
T[]getItems(T[] items, int[] indices)
get Items
T[] result = Arrays.copyOf(items, indices.length);
for (int i = 0; i < indices.length; i++)
    result[i] = items[indices[i]];
return result;
Tgetlast(final T[] array)
getlast
return array == null || array.length == 0 ? null : array[array.length - 1];
TgetLast(T[] l)
get Last
return get(l, -1);