Wednesday, 16 May 2018


Write a program to identify common elements or numbers between
two given arrays. You should not use any inbuilt methods are list to
find common values.


package govind;

public class TwoArrayCommonElement {
            public static void main(String[] args) {
                        int x[]= {10,20,30,40,50,60,70,80,90,100};
                        int y[]= {1,2,3,10,4,5,6,20,60,100};
                        for(int i=0;i<x.length;i++)
                        {
                                    for(int j=0;j<y.length;j++)
                                    {
                                                if(x[i]==y[j])
                                                {
                                                System.out.println(x[i]);
                                                }
                                               
                                    }
                        }
            }

}


o/p:------------------------------

10
20
60
100





No comments:

Post a Comment