Advertisement
YankoZlatanov

Untitled

Feb 10th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class CombineListsOfLetters {
  6.  
  7.     public static void main(String[] args){
  8.        
  9.         Scanner input = new Scanner(System.in);
  10.        
  11.         String input_one = input.nextLine();
  12.        
  13.         String input_two = input.nextLine();
  14.        
  15.         char[] chars_one = input_one.toCharArray();
  16.        
  17.         char[] chars_two = input_two.toCharArray();
  18.        
  19.         ArrayList<Character> result = new ArrayList<Character>();
  20.        
  21.         ArrayList<Character> check = new ArrayList<Character>();
  22.        
  23.         for (Character character : chars_one) {
  24.             result.add(character);
  25.             check.add(character);
  26.         }
  27.        
  28.        
  29.             for (int j = 0; j < chars_two.length; j++) {
  30.                 if (!check.contains(chars_two[j])) {
  31.                     result.add(' ');
  32.                     result.add(chars_two[j]);
  33.                 }
  34.             }
  35.        
  36.         for (Character character : result) {
  37.             System.out.print(character);
  38.         }
  39.         input.close();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement