Returns intersection of given String arrays. If either array is {@code null}, then {@code null} is returned.

@param arr1 first array
@param arr2 second array
@return arr1 without values which are not present in arr2
969984
public static String[] intersection(String[] arr1, String[] arr2) {
        if (arr1 == null || arr2 == null) {
            return null;
        }
        if (arr1.length == 0 || arr2.length == 0) {
            return new String[0];
        }
        List<String> list = new ArrayList<String>(Arrays.asList(arr1));
        list.retainAll(Arrays.asList(arr2));
        return list.toArray(new String[0]);
    }
504182
function equalSimpleArrays(arr1, arr2) {

	if (arr1 && (arr1.length > 0))
		return (
			arr2 &&
				(arr2.length === arr1.length) &&
				arr2.every((v, i) => (v === arr1[i]))
		);

	return (!arr2 || (arr2.length === 0));
}
482079
public static boolean overlap(@Nullable String[] as, @Nullable String[] bs)
  {
    if (as == null || bs == null) {
      // They only have overlap if both are null.
      return as == null && bs == null;
    }
    if (as.length == 0 && bs.length == 0) {
      return true;
    }

    for (String a : as) {
      for (String b : bs) {
        if (Objects.equals(a, b)) {
          return true;
        }
      }
    }

    return false;
  }
503419
public static String join(long[] array, CharSequence conjunction) {
		if (null == array) {
			return null;
		}

		final StringBuilder sb = new StringBuilder();
		boolean isFirst = true;
		for (long item : array) {
			if (isFirst) {
				isFirst = false;
			} else {
				sb.append(conjunction);
			}
			sb.append(item);
		}
		return sb.toString();
	}
627652
public static String intersectSeq(final String first, final String second, final String delimiter) {
    if (isEmpty(first) || isEmpty(second)) { return ""; }
    List<String> firstSeq = Arrays.asList(split(first, ','));
    List<String> secondSeq = Arrays.asList(split(second, ','));
    Collection<String> rs = CollectUtils.intersection(firstSeq, secondSeq);
    StringBuilder buf = new StringBuilder();
    for (final String ele : rs) {
      buf.append(delimiter).append(ele);
    }
    if (buf.length() > 0) {
      buf.append(delimiter);
    }
    return buf.toString();
  }
464707
function (x1, y1, x2, y2) {
		var polygons = this.polygons;
		for (var i = 0, n = polygons.length; i < n; i++)
			if (polygons[i].intersectsSegment(x1, y1, x2, y2)) return this.boundingBoxes[i];
		return null;
	}
1365499
public static String[] minus(String[] arr1, String[] arr2) {
		LinkedList<String> list = new LinkedList<String>();
		LinkedList<String> history = new LinkedList<String>();
		String[] longerArr = arr1;
		String[] shorterArr = arr2;
		if (arr1.length > arr2.length) {
			longerArr = arr2;
			shorterArr = arr1;
		}
		for (String str : longerArr) {
			if (!list.contains(str)) {
				list.add(str);
			}
		}
		for (String str : shorterArr) {
			if (list.contains(str)) {
				history.add(str);
				list.remove(str);
			} else {
				if (!history.contains(str)) {
					list.add(str);
				}
			}
		}

		String[] result = {};
		return list.toArray(result);
	}
578716
public static <T> List<T> intersection(final List<? extends T> list1, final List<? extends T> list2) {
		List<? extends T> smaller = list1;
		List<? extends T> larger = list2;
		if (list1.size() > list2.size()) {
			smaller = list2;
			larger = list1;
		}

		// 克隆一个可修改的副本
		List<T> newSmaller = new ArrayList<T>(smaller);
		List<T> result = new ArrayList<T>(smaller.size());
		for (final T e : larger) {
			if (newSmaller.contains(e)) {
				result.add(e);
				newSmaller.remove(e);
			}
		}
		return result;
	}
579280
public static String[] union(String[] arr1, String[] arr2) {
		Set<String> set = new HashSet<String>();
		for (String str : arr1) {
			set.add(str);
		}
		for (String str : arr2) {
			set.add(str);
		}
		String[] result = {};
		return set.toArray(result);
	}
252116
public static boolean isStringArrayEmpty(String[] arr) {
        boolean empty = true;
        if (arr != null) {
            if (arr.length > 0) {
                for (String s : arr) {
                    if (StringUtils.isNotBlank(s)) {
                        empty = false;
                        break;
                    }
                }
            }
        }
        return empty;
    }
420560
public static String[] intersect(
      Comparator<? super String> comparator, String[] first, String[] second) {
    List<String> result = new ArrayList<>();
    for (String a : first) {
      for (String b : second) {
        if (comparator.compare(a, b) == 0) {
          result.add(a);
          break;
        }
      }
    }
    return result.toArray(new String[0]);
  }
897612
def compare_arrays(a, b)
      a.each_with_index do |v1, i|
        v2 = b[i]
        if v1.is_a?(String) && v2.is_a?(Integer)
          return 1
        elsif v1.is_a?(Integer) && v2.is_a?(String)
          return -1
        end
        comparison = v1 <=> v2
        unless comparison == 0
          return comparison
        end
      end
      0
    end
1040855
public static boolean compareStringLists(List<String> list1, List<String> list2) {
        if (list1 == null && list2 == null)
            return true;
        if (list1 == null || list2 == null)
            return false;
        if (list1.size() != list2.size())
            return false;
        for (int i = 0; i < list1.size(); i++) {
            if (!compareStrings(list1.get(i), list2.get(i))) {
                return false;
            }
        }

        return true;
    }
1007306
function (array1, array2) {
                return array1.every(function (element) {
                    return array2.includes(element);
                }) && array1.length === array2.length;
            }
1323202
def intersection
			array = self.sort_elements
			array.inject() do |common, element|
				value_first = comparison_value(common, :last)
				value_element = comparison_value(element, :first)
				case value_first <=> value_element
				when -1 then return nil
				when 0 then value_first
				else
					if element.class == Range 
						value_element..([value_first, comparison_value(element, :last)].min)
					else
						value_element
					end
				end
			end
		end
419636
public static Object[] concat(Object array1[], Object array2[]){
        Class<?> class1 = array1.getClass().getComponentType();
        Class<?> class2 = array2.getClass().getComponentType();
        Class<?> commonClass = class1.isAssignableFrom(class2)
                                    ? class1
                                    : (class2.isAssignableFrom(class1) ? class2 : Object.class);
        return concat(array1, array2, commonClass);
    }
811829
public int compare(T o1, T o2) {
	if(o1 == o2)   return 0;
	String str1 = (o1 == null) ? "null" : o1.toString(); 
	String str2 = (o2 == null) ? "null" : o2.toString();
	return str1.compareTo(str2);
    }