Java Utililty Methods Array Remove

List of utility methods to do Array Remove

Description

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

Method

double[]removeNaN(double[] x1)
remove Na N
int i;
for (i = 0; i < x1.length; i++) {
    if (Double.isNaN(x1[i])) {
        break;
i = i > x1.length ? x1.length : i;
return Arrays.copyOf(x1, i);
...
T[]removeNodes(T[] array, T sampleNode)
remove Nodes
List<T> reducedList = new ArrayList<>();
for (T node : array) {
    if (!node.equals(sampleNode)) {
        reducedList.add(node);
return (T[]) reducedList.toArray();
T[]removeNull(T[] data)
remove Null
ArrayList<T> temp = new ArrayList();
for (T f : data)
    if (f != null)
        temp.add(f);
return temp.toArray(data);
String[]removeNullElements(String[] x)
Returns a new String array of non-empty data only
List<String> sl = new ArrayList<String>();
for (String s : x) {
    if (s != null) {
        sl.add(s);
return sl.toArray(new String[sl.size()]);
Object[]removeNulls(Object[] arr)
Removes all null elements in an Object array.
ArrayList<Object> reply = new ArrayList<Object>(arr.length);
for (int i = 0; i < arr.length; i++) {
    if (arr[i] != null)
        reply.add(arr[i]);
return reply.toArray();
T[]removeNulls(T[] array)
remove Nulls
for (T t : array) {
    if (t == null) {
        List<T> list = new ArrayList<>();
        for (T t2 : array)
            if (t2 != null)
                list.add(t2);
        return list.toArray(Arrays.copyOf(array, list.size()));
return array;
T[]removeNulls(T[] array)
remove Nulls
for (T t : array) {
    if (t == null) {
        List<T> list = new ArrayList<>();
        for (T t2 : array)
            if (t2 != null)
                list.add(t2);
        return list.toArray(Arrays.copyOf(array, list.size()));
return array;
T[]removeNulls(T[] input)
remove Nulls
int pos = 0;
for (int i = 0; i < input.length; i++) {
    if (input[i] != null) {
        if (i > pos)
            input[pos] = input[i];
        pos++;
return Arrays.copyOf(input, pos);
String[]removeNullsFromStringArray(String[] array)
remove Nulls From String Array
ArrayList<String> arrayList = new ArrayList<String>();
for (int i = 0; i < array.length; i++) {
    if (array[i] != null && !array[i].equals("")) {
        arrayList.add(array[i]);
String[] newArray = arrayList.toArray(new String[arrayList.size()]);
return newArray;
...
ArrayListremoveOwnCookieNameFromCookieHeader(String ownCookieName, String[] cookies)
remove Own Cookie Name From Cookie Header
ArrayList<String> newCookies = new ArrayList<>();
for (String cookie : cookies)
    if (!cookie.trim().startsWith(ownCookieName))
        newCookies.add(cookie.trim());
return newCookies;