Hello together,
I was about to play with the
Java 8 Map API. Following my code:
so far, so good. But the situation which makes me confused, is the following:
if I want to sort my Map and display the content of the map, I can write something like this:
eclipse Neon returns the following warning: Type safety: Unchecked cast from Object to Map.Entry<String, String>
Question 1: why do I have the warning?
to avoid the warning I changed the code like this, after have seen a similar code in internet:
Question 2: could somebody help me to decrypt the syntax used? In other words what the hell should this weird syntax mean?
Map.Entry.<String,String>comparingByKey().... e.g. the diamond operator direct after the point, directly followed by a function.
Why is it necessary, to write it so komplex? Probably I have to learn something concerning the generics.
thanks for helping