|
6 | 6 | * Write a Java Program to find the intersection of |
7 | 7 | * Two Arrays |
8 | 8 | * |
9 | | - * say array1 = {1, 2, 3, 4, 5, 6} |
10 | | - * say array2 = {2, 4, 6, 8,10} |
| 9 | + * INTERSECTION |
| 10 | + * Common element in both arrays. |
| 11 | + * Intersection array elements are should be |
| 12 | + * present in both array1 and array2 |
| 13 | + * |
| 14 | + * say array1 = {44, 49, 30, 25, 67, 69}; |
| 15 | + * say array2 = {88, 44, 69, 93, 30}; |
11 | 16 | * |
12 | 17 | * intersection of two array is |
13 | | - * intersection = {2, 4, 6} |
| 18 | + * intersection = {44, 30, 69} |
14 | 19 | */ |
15 | 20 |
|
16 | | -public class ArrayIntersection { |
| 21 | +public class IntersectionOfTwoArrays { |
17 | 22 | public static void main(String[] args) { |
18 | | - int array1[] = {1, 2, 3, 4, 5, 6}; |
19 | | - int array2[] = {2, 4, 6, 8, 10}; |
| 23 | + int array1[] = {44, 49, 30, 25, 67, 69}; |
| 24 | + int array2[] = {88, 44, 69, 93, 30}; |
20 | 25 |
|
21 | 26 | System.out.println("Given array 1 is : "); |
22 | 27 | for(int v : array1) |
@@ -49,8 +54,8 @@ public static void main(String[] args) { |
49 | 54 | } |
50 | 55 | /* |
51 | 56 | OUTPUT |
52 | | - Given array 1 is : 1 2 3 4 5 6 |
53 | | - Given array 2 is : 2 4 6 8 10 |
54 | | - Intersection of the array 1 & 2 is : 2 4 6 |
| 57 | + Given array 1 is : 44 49 30 25 67 69 |
| 58 | + Given array 2 is : 88 44 69 93 30 |
| 59 | + Intersection of the array 1 & 2 is : 44 30 69 |
55 | 60 | */ |
56 | 61 |
|
0 commit comments