Advertisement
coasterka

#4CombineListsOfLetters

Jun 3rd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.HashSet;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class CombineListsOfLetters {
  7.  
  8.     public static void main(String[] args) {
  9.  
  10.         Scanner scan = new Scanner(System.in);
  11.         List<String> firstList = new ArrayList<String>();
  12.         firstList.add(scan.nextLine());
  13.         List<String> secondList = new ArrayList<String>();
  14.         secondList.add(scan.nextLine());
  15.         List<String> newList = new ArrayList<>();
  16.         newList.addAll(firstList);
  17.         newList.addAll(secondList);
  18.         HashSet<String> hs = new HashSet<>(firstList);
  19.         firstList.removeAll(newList);
  20.         newList.removeAll(hs);
  21.         System.out.print(newList);
  22.     }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement