How to Find Common Element In Two arrays – java program

package com.javaproficiency;

public class CommonElementOfTwoArray {

public static void main(String[] args) {

int []arr = {10,15,20,25,40};
int []brr ={5,18,20,25,30,10};

for( int i=0 ; i < arr.length ; i++ ){
for( int j=0 ; j < brr.length ; j++  ){
if(arr[i] == brr[j])
System.out.println(arr[i]);
}
}

}

}

Output:
10
20
25

 

Leave a Reply

Your email address will not be published. Required fields are marked *

77 + = 86