Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class commonElements {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String[] arr1 = scan.nextLine().split(" ");
- String[] arr2 = scan.nextLine().split(" ");
- for (int i = 0; i <= arr1.length - 1; i++) {
- for (int j = 0; j <= arr2.length - 1; j++) {
- if (arr2[j].equals(arr1[i])) {
- System.out.print(arr2[j] + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment