Help the world stop coronavirus! Stay home!

Prev Next

Java / Operators

Explain Diamond Operator in Java.

<> denotes the diamond operator. Purpose of the diamond operator is to simplify instantiation of generic classes.

For example, see the below.

List<Integer> myList = new ArrayList<Integer>(); 
//with the diamond operator we can write as below easily.

List<Integer> myList = new ArrayList<>(); 

The Diamond Operator reduces some of Java's verbosity surrounding generics by having the compiler infer parameter types for constructors of generic classes.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

Package

Comments & Discussions