What is he difference between two approaches of instantiating a map:
Map<String, String> map = new TreeMap<String, String>();
and
Map<String, String> map = new TreeMap<>();
and which one is better?
They are equivalent. The second syntax (known as the diamond operator) was added in Java 7 and allows you to type less code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With