Java Array Intersect intersection(String[] ary1, String[] ary2)

Here you can find the source of intersection(String[] ary1, String[] ary2)

Description

intersection

License

Open Source License

Declaration

public static String[] intersection(String[] ary1, String[] ary2) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {

    public static String[] intersection(String[] ary1, String[] ary2) {
        List<String> list1 = new ArrayList<String>(Arrays.asList(ary1));
        List<String> list2 = new ArrayList<String>(Arrays.asList(ary2));
        list1.retainAll(list2);//from   w w  w  .  j ava2s  . co  m
        return list1.toArray(new String[0]);
    }
}

Related

  1. intersect(T[] a, T[] b)
  2. intersectArrays(int[] a, int[] b)
  3. intersectArrays(int[] targetArray, int[] selfArray)
  4. intersection(final long[] array1, final long[] array2)
  5. intersection(int[] array1, int[] array2)
  6. intersection(String[] ss1, String[] ss2)
  7. intersectRanges(int[] range1, int[] range2)
  8. isArrayIntersect(Object[] objArr1, Object[] objArr2)