import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
class Frequencias {
public static void main
(String[] args
) { List<String> dados = new ArrayList<>();
dados.add("Dado 2");
dados.add("Dado 1");
dados.add("Dado 3");
dados.add("Dado 3");
dados.add("Dado 2");
dados.add("Dado 1");
dados.add("Dado 3");
dados.add("Dado 3");
Map
<String, Integer
> frequencias
= new TreeMap
<>(); frequencias.compute(c, (k, v) -> v == null ? 1 : v + 1);
}
frequencias.
forEach((k, v
) -> System.
out.
println(k
+ " aparece " + v
+ " vezes.")); }
}
aW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CmltcG9ydCBqYXZhLnV0aWwuTGlzdDsKaW1wb3J0IGphdmEudXRpbC5NYXA7CmltcG9ydCBqYXZhLnV0aWwuVHJlZU1hcDsKCmNsYXNzIEZyZXF1ZW5jaWFzIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBMaXN0PFN0cmluZz4gZGFkb3MgPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICBkYWRvcy5hZGQoIkRhZG8gMiIpOwogICAgICAgIGRhZG9zLmFkZCgiRGFkbyAxIik7CiAgICAgICAgZGFkb3MuYWRkKCJEYWRvIDMiKTsKICAgICAgICBkYWRvcy5hZGQoIkRhZG8gMyIpOwogICAgICAgIGRhZG9zLmFkZCgiRGFkbyAyIik7CiAgICAgICAgZGFkb3MuYWRkKCJEYWRvIDEiKTsKICAgICAgICBkYWRvcy5hZGQoIkRhZG8gMyIpOwogICAgICAgIGRhZG9zLmFkZCgiRGFkbyAzIik7CgogICAgICAgIE1hcDxTdHJpbmcsIEludGVnZXI+IGZyZXF1ZW5jaWFzID0gbmV3IFRyZWVNYXA8PigpOwogICAgICAgIGZvciAoU3RyaW5nIGMgOiBkYWRvcykgewogICAgICAgICAgICBmcmVxdWVuY2lhcy5jb21wdXRlKGMsIChrLCB2KSAtPiB2ID09IG51bGwgPyAxIDogdiArIDEpOwogICAgICAgIH0KCiAgICAgICAgZnJlcXVlbmNpYXMuZm9yRWFjaCgoaywgdikgLT4gU3lzdGVtLm91dC5wcmludGxuKGsgKyAiIGFwYXJlY2UgIiArIHYgKyAiIHZlemVzLiIpKTsKICAgIH0KfQ==