Java Array Intersect getArrayIntersection(int a[], int b[])

Here you can find the source of getArrayIntersection(int a[], int b[])

Description

get Array Intersection

License

Apache License

Declaration

public static int[] getArrayIntersection(int a[], int b[]) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static int[] getArrayIntersection(int a[], int b[]) {
        return Arrays.stream(a).flatMap(i -> Arrays.stream(b).filter(j -> i == j)).distinct().toArray();
    }//from   w  w w .  j  a  v  a2s  .  c om
}

Related

  1. arrayInterp(double[] inputArray, double index)
  2. arraysIntersect(Object[] array1, Object[] array2)
  3. byteIntersection(byte[] a, byte[] b)
  4. getNonIntersection(int[] interval, int[] intervalToRemove)
  5. hasIntersection(String a1[], String a2[], int mode)
  6. intersect(boolean[] mask, int[] examples, boolean[] intersection)
  7. intersect(int[] sorted1, int[] sorted2)