Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class _09_CombineListsOfLetters {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- ArrayList<Character> firstLine = new ArrayList<>();
- ArrayList<Character> secondLine = new ArrayList<>();
- ArrayList<Character> result = new ArrayList<>();
- for(char ch : sc.nextLine().toCharArray()){
- firstLine.add(ch);
- }
- for(char ch : sc.nextLine().toCharArray()){
- secondLine.add(ch);
- }
- result.addAll(firstLine);
- for (int i = 0; i < secondLine.size(); i++) {
- if(firstLine.contains(secondLine.get(i))){
- continue;
- }
- else {
- result.add(' ');
- result.add(secondLine.get(i));
- }
- }
- for (int i = 0; i < result.size(); i++) {
- System.out.print(result.get(i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment