Can you please explain, whi in IDE (idea) if 2 numbers equal - i see correct result, but check fails only for two exact numbers?
I'v changed spaces between digits being printed - did not helped
package com.codegym.task.task04.task0417;
/*
Do we have a pair?
*/
import java.util.*;
public class Solution {
private static Map<Integer, Integer> hMap = new HashMap<>();
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
int val = 0;
int total = 3;
for (int i = 0; i < total; i++) {
val = scanner.nextInt();
hMap.put(val, hMap.containsKey(val) ? hMap.get(val) + 1 : 1);
}
hMap.entrySet().stream().filter(en -> en.getValue() > 1).forEach(e -> printDuplicates(e.getKey(), e.getValue()));
}
private static void printDuplicates(int key, int count) {
for (int i = 0; i < count; i++) {
System.out.print(key + " ");
}
}
}