It really should look like
private Map<String, String> test = new HashMap<>();
So, the elements of both are correct;) A map is an interface that defines behavior, and a HashMap is an implementation that provides behavior.
If you need stronger security, you should use general arguments. Although not strictly necessary, they add more value to reduce application errors. Since generics were introduced in Java 5, the examples from earlier will not show general arguments.
The "diamond operator" <> was introduced with Java 7 - this means that you can reduce the second occurrence of a type specifier to just <>.
source share