Guest User

Untitled

a guest
May 24th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class _09_CombineListsOfLetters {
  5.  
  6.     public static void main(String[] args) {
  7.        
  8.         Scanner sc = new Scanner(System.in);
  9.        
  10.         ArrayList<Character> firstLine = new ArrayList<>();
  11.         ArrayList<Character> secondLine = new ArrayList<>();
  12.         ArrayList<Character> result = new ArrayList<>();
  13.        
  14.        
  15.         for(char ch : sc.nextLine().toCharArray()){
  16.             firstLine.add(ch);
  17.         }
  18.         for(char ch : sc.nextLine().toCharArray()){
  19.             secondLine.add(ch);
  20.         }
  21.        
  22.         result.addAll(firstLine);
  23.        
  24.         for (int i = 0; i < secondLine.size(); i++) {
  25.            
  26.             if(firstLine.contains(secondLine.get(i))){
  27.                 continue;
  28.             }
  29.             else {
  30.                 result.add(' ');
  31.                 result.add(secondLine.get(i));
  32.             }
  33.         }
  34.        
  35.         for (int i = 0; i < result.size(); i++) {
  36.             System.out.print(result.get(i));
  37.         }
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment