Diamond Operator in Java Generics
In JavaSE 7 or later you can replace the type arguments eg., 'String, Integer' with empty set of type arguments "<>". As long as compiler can determine or can do type inference, the type arguments.
This pair of angle brackets "<>" is called as diamond operator.
For example you can create an instance of IGenericEntry with the following statement:
IGenericEntry entry1 = new GenericEntryImpl<>("Nithi", 30);
instead of
IGenericEntry entry1 = new GenericEntryImpl("Nithi", 30);
This pair of angle brackets "<>" is called as diamond operator.
For example you can create an instance of IGenericEntry
IGenericEntry
instead of
IGenericEntry
0 comments:
Post a Comment