Advertisement
pashunov151

Combine Lists

Apr 11th, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Digits {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String[] name = scanner.nextLine().split(",");
  7.         List<String> listOne  = Arrays.asList(name);
  8.         List<Integer> intList = new ArrayList<>();
  9.  
  10.         for (String elem :listOne) {
  11.             intList.add(Integer.parseInt(elem));
  12.         }
  13.        // System.out.println(intList);
  14.  
  15.         String[] name2 = scanner.nextLine().split(",");
  16.         List<String> listTwo = Arrays.asList(name2);
  17.         List<Integer> intListTwo = new ArrayList<>(intList);
  18.         for (String elem2 :listTwo) {
  19.             intListTwo.add(Integer.parseInt(elem2));
  20.         }
  21.         List<String> resultTwo = new ArrayList<>();
  22.         for (Integer elem3 :intListTwo) {
  23.             resultTwo.add(Integer.toString(elem3));
  24.         }
  25.         String result = String.join(",", resultTwo);
  26.         System.out.println(result);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement