Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DPM;
- import java.text.DecimalFormat;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int num = Integer.parseInt(scan.nextLine());
- Map <String, List<String>> newMap = new LinkedHashMap<>();
- for (int i = 0; i < num; i++) {
- String str1 = scan.nextLine();
- String str2 = scan.nextLine();
- newMap.putIfAbsent(str1, new ArrayList<>());
- newMap.get(str1).add(str2);
- }
- for (Map.Entry<String, List<String>> entry : newMap.entrySet()) {
- String value1 = String.join(", ", entry.getValue());
- System.out.printf("%s - %s\n", entry.getKey(), value1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement