Showing posts with label find common element in two arrays.java example. Show all posts
Showing posts with label find common element in two arrays.java example. Show all posts

Monday, 30 November 2015

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