Write a program in java that will be able to print out the duplicates of numbers

import java.util.*;

public class Duplicates {

public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5, 2, 4, 6, 8, 1};

Map<Integer, Integer> numCount = new HashMap<>();

for (int num : numbers) {
if (numCount.containsKey(num)) {
numCount.put(num, numCount.get(num) + 1);
} else {
numCount.put(num, 1);
}
}

for (int num : numCount.keySet()) {
if (numCount.get(num) > 1) {
System.out.println(num + " is a duplicate.");
}
}
}
}