this is My code >>>

i advise you to solve it by own but if you cannot you can use my code ...

Code:

import java.io.*;
public class Sharing
{
public static void main(String[]args) throws IOException
{
InputStreamReader s = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(s);
System.out.print("Eneter the Size of the First Array: ");
int array1_size = Integer.parseInt(stdin.readLine());
System.out.print("Eneter the Size of the Second Array: ");
int array2_size = Integer.parseInt(stdin.readLine());
int [] array1 = new int[array1_size];
int [] array2 = new int[array2_size];
for (int i=0;i<array1_size;i++)
{
System.out.print("Eneter the "+i+" Element of the First Array: ");
array1[i]=Integer.parseInt(stdin.readLine());
}
for (int i=0;i<array2_size;i++)
{
System.out.print("Eneter the "+i+" Element of the Second Array: ");
array2[i]=Integer.parseInt(stdin.readLine());
}
int array3_size=0;
for(int i=0;i<array1_size;i++)
{
for (int j=0;j<array2_size;j++)
{
if(array1[i]==array2[j])
array3_size++;
}
}
int[]array3 = new int[array3_size];
int k=0;
for(int i=0;i<array1_size;i++)
{
for (int j=0;j<array2_size;j++)
{
if(array1[i]==array2[j])
{
array3[k]=array1[i];
k++;
}
}
}
System.out.print("[ ");
for (int i=0;i<array3_size;i++)
System.out.print(array3[i]+" ");
System.out.print("]"+"\n");
}
}

regards,