Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a program, which prints common elements in two arrays. You have to compare the elements of the second array to the elements of the first.*/
- import java.util.Scanner;
- public class TestXXX {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] first = scanner.nextLine().split(" ");
- String[] second = scanner.nextLine().split(" ");
- for (String s2 : second) {
- for (String s1 : first) {
- if (s2.equals(s1)){
- System.out.print(s2 + " ");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment