PROGRAM OF CALCULATING INTERSECTION OF TWO ARRAYS
PROGRAM FINDING OUT INTERSECTION OF TWO GIVEN ARRAYS
import java.lang.reflect.Array;
import java.util.Arrays;
public class IntersectionOfAnArrays {
public static void main (String [] args){
int arr1[] ={4,1,5,2,3,9};
int arr2[] ={5,6,7,4,8,9};
// int[] arr3 = new int[10];
Arrays.sort(arr1);
Arrays.sort(arr2);
for(int i =0 ; i<arr1.length ; i++){
for (int j =0; j<arr2.length ; j++){
if(arr1[i]==arr2[j]){
System.out.print(arr1[i] + " ");
}
}
}
Comments
Post a Comment