Let\'s say I have the following two arrays:
int[] a = [1,2,3,4,5];
int[] b = [8,1,3,9,4];
I would like to take the first value of array
Since you haven't got this tagged as homework, I'll give you the benefit of the doubt. As you said you'll need two loops; loop foreach int in a[] and foreach int in b[]. Then just compare the two values at each iteration, which gives you the simple code of:
for (int x : a) {
for (int y : b) {
if (x == y) {
System.out.println("a[] and b[] both contain " + x);
}
}
}