Java 7 feature: Advanced type inference in generics

Before java 7, while using generics you had to supply type parameters to variables types and to their actual types. Now, it has been relieved a bit in this new java 7 feature, and a blank diamond on right side of declaration will work properly. Java 7 Compiler will identify that blank diamond infer to type defined on left hand side of declaration.

public class JavastuffOper {
 public static void main(String[] args) {
 Map<string , Double> params = new HashMap<>();
 // Rest of the code
  }
 }

Search:

Recent Posts