Could anyone help me in understanding what does below Python code do? Also please help me in converting it into Java.
import random
howMany = random.randint(0,1000)
stats = {}
for i in range(howMany):
value = random.randint(0,500)
stats.setdefault(value,0)
stats[value]+=1
for item in stats:
if stats[item] > 1:
print item