JavaBeginner#generics

What is the diamond operator in generics?

Introduced in Java 7, it lets you omit the explicit type argument on the right-hand side of a generic instantiation, since the compiler infers it from the declared variable type.

Example
List<Map<String, Integer>> list = new ArrayList<>(); // <> infers Map<String,Integer>

Related Questions

1
JavaBeginner#exceptions

What is the exception hierarchy in Java?

Open
2
JavaBeginner#exceptions

What is a custom exception and how do you create one?

Open
3
JavaIntermediate#exceptions

What is exception chaining (cause)?

Open