Created
April 25, 2020 20:15
-
-
Save raviyasas/08c0c0e19dc5c160ad4b16b097ce30aa to your computer and use it in GitHub Desktop.
Common elements of two arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.app.interviews; | |
public class CommonElements { | |
public static void main(String args[]) { | |
int[] a = {1, 2, 3, 4, 5}; | |
int[] b = {2, 3, 4, 5, 6, 7, 8}; | |
for (int i = 0; i < a.length; i++) { | |
for (int j = 0; j < b.length; j++) { | |
if (a[i] == b[j]) { | |
System.out.println(a[i]); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment