Try it like this for a frequency. Note that a map can't have duplicate keys.
List list2 = List.of("5", "7", "5", "8", "9","8");
the key is the String.
the value starts a 1.
the Integers::sum adds 1 for every occurrence.
Map freq = list2.stream().collect(Collectors.toMap(
e->e, (a)->1, Integer::sum));
freq.entrySet().forEach(System.out::println);
prints
5=2
7=1
8=2
9=1
for the second task, to convert the strings to ints is trivial. But remember that dups can't exist so they have to be properly merged. This is similar to the first task except instead of counting we're just converting to an integer. Since you have duplicate integers, you need to provide instructions on what to do. That is the merge function (a,b)->a which says for existing value a and new value b, just keep a
List list2 = List.of("5", "7", "5", "8", "9","8");
Map map = list2.stream().collectCollectors.toMap(e->e,
Integer::valueOf,
(a,b)->a); // just keep the first one
prints
5=5
7=7
8=8
9=9