Advertisement
a1m

Combine Lists of Letters

a1m
Sep 10th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Problem_09_CombineListsOfLetters {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String firstText = scanner.nextLine();
  7.         String secondText = scanner.nextLine();
  8.         StringBuilder sb = new StringBuilder();
  9.         sb.append(firstText+ " ");
  10.         for (int i = 0; i < secondText.length(); i++) {
  11.             for (int j = 0; j < firstText.length(); j++) {
  12.                 if (secondText.charAt(i) == firstText.charAt(j)) {
  13.                     break;
  14.                 }
  15.                 if (j == firstText.length()-1) {
  16.                 sb.append(secondText.charAt(i)+" ");
  17.                 }
  18.             }
  19.         }
  20.         System.out.println(sb);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement