-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppendArrays.java
More file actions
26 lines (20 loc) · 798 Bytes
/
Copy pathAppendArrays.java
File metadata and controls
26 lines (20 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Lists;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class AppendArrays {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<String> numbersList = Arrays.stream(scanner.nextLine().split("\\|")).collect(Collectors.toList());
Collections.reverse(numbersList);
// String noSpaces = numbersList.toString().replaceAll("[\\[\\], \\s+]","");
String noSpaces = numbersList.toString().replaceAll("[\\[\\],]","");
noSpaces = noSpaces.replaceAll("\\s+","");
char[] numbers= noSpaces.toCharArray();
for (char element:numbers) {
System.out.print(element + " ");
}
}
}