Skip to content

Instantly share code, notes, and snippets.

@raviyasas
Created April 25, 2020 20:15
Show Gist options
  • Save raviyasas/08c0c0e19dc5c160ad4b16b097ce30aa to your computer and use it in GitHub Desktop.
Save raviyasas/08c0c0e19dc5c160ad4b16b097ce30aa to your computer and use it in GitHub Desktop.
Common elements of two arrays
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