public static <T> T[] removeAll(T[] items, T item) {
		int count = 0;
		// First, determine the number of elements which will be removed
		for (int i = 0; i != items.length; ++i) {
			T ith = items[i];
			if (ith == item || (item != null && item.equals(ith))) {
				count++;
			}
		}
		// Second, eliminate duplicates (if any)
		if (count == 0) {
			// nothing actually needs to be removed
			return items;
		} else {
			T[] nItems = Arrays.copyOf(items, items.length - count);
			for(int i=0, j = 0;i!=items.length;++i) {
				T ith = items[i];
				if (ith == item || (item != null && item.equals(ith))) {
					// skip item
				} else {
					nItems[j++] = ith;
				}
			}
			return nItems;
		}
	}
public static <T> T[] removeAll(T[] items, T item) {
		int count = 0;
		
		for (int i = 0; i != items.length; ++i) {
			T ith = items[i];
			if (ith == item || (item != null && item.equals(ith))) {
				count++;
			}
		}
		
		if (count == 0) {
			
			return items;
		} else {
			T[] nItems = Arrays.copyOf(items, items.length - count);
			for(int i=0, j = 0;i!=items.length;++i) {
				T ith = items[i];
				if (ith == item || (item != null && item.equals(ith))) {
					
				} else {
					nItems[j++] = ith;
				}
			}
			return nItems;
		}
	}
public static < T > T [ ] removeAll ( T [ ] items , T item ) { int count = 0 ; // First, determine the number of elements which will be removed for ( int i = 0 ; i != items . length ; ++ i ) { T ith = items [ i ] ; if ( ith == item || ( item != null && item . equals ( ith ) ) ) { count ++ ; } } // Second, eliminate duplicates (if any) if ( count == 0 ) { // nothing actually needs to be removed return items ; } else { T [ ] nItems = Arrays . copyOf ( items , items . length - count ) ; for ( int i = 0 , j = 0 ; i != items . length ; ++ i ) { T ith = items [ i ] ; if ( ith == item || ( item != null && item . equals ( ith ) ) ) { // skip item } else { nItems [ j ++ ] = ith ; } } return nItems ; } }
Remove any occurrence of a given value from an array. The resulting array
may be shorter in length, but the relative position of all other items
will remain unchanged. This algorithm is robust to <code>null</code>. The
<code>items</code> array may contain <code>null</code> values and the
<code>item</code> may itself be <code>null</code> (in which case, all
<code>null</code> values are removed).

@param items
@return
Remove any occurrence of a given value from an array . The resulting array may be shorter in length but the relative position of all other items will remain unchanged . This algorithm is robust to <code > null< / code > . The <code > items< / code > array may contain <code > null< / code > values and the <code > item< / code > may itself be <code > null< / code > ( in which case all <code > null< / code > values are removed ) .