find common element in two given arrays

find common element in two given arrays
SOURCE : CommonArrayElement.java



public class CommonArrayElement {

public static void main(String[] args) {


int[] arr1 = {4,7,3,9,2};
int[] arr2 = {3,2,12,9,40,32,4};
try {
for(int i=0;i for(int j=0;j if(arr1[i]==arr2[j]){
System.out.println(arr1[i]);
}
}

}
} catch (Exception e) {
// TODO: handle exception
}


}

}


INPUT

int[] arr1 = {4,7,3,9,2};
int[] arr2 = {3,2,12,9,40,32,4};



OUTPUT

4
3
9
2







Sandeep Kumar D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Sandeep Kumar D

Follow Me @Google+




SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment