0% found this document useful (0 votes)
2 views

java equality of arrays

Uploaded by

fojimaw327
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java equality of arrays

Uploaded by

fojimaw327
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;
public class Main
{
public static void main(String[] args)
{
int i,j,count;
Scanner sc= new Scanner(System.in);

System.out.println("Enter the number of elements in each array");


int n=sc.nextInt();

int a[]=new int[n];


System.out.println("Enter the array 1 elements");
for(i=0;i<n;i++)
{
int num=sc.nextInt();
a[i]=num;
}

int b[]=new int[n];


System.out.println("Enter the array 2 elements");
for(j=0;j<n;j++)
{
int num=sc.nextInt();
b[j]=num;
}

System.out.println("The elements of array 1 are");


for(i=0;i<n;i++)
{
System.out.println(" "+a[i]);
}

System.out.println("The elements of array 2 are");


for(j=0;j<n;j++)
{
System.out.println(" "+b[j]);
}

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]==b[j])
{
System.out.println("Both the arrays have same element");
break;
}
else
{
System.out.println("Both the array do not have same element");
break;
}
}
}
}
}

You might also like