Reputation: 115
when pressing ctrl+space in eclipse I remember it used to match the objects for the data type in the diamond operator. but it dosn't anymore . for example :
public static void main(String[] args) {
HashMap<String, String> map = new HashMap<**MISSING**>()
}
anyway to turn it back on? thnx.
Upvotes: 0
Views: 86
Reputation: 93862
Are you running Java 7 ?
It's a new feature they added called "Type Inference for Generic Instance Creation"
You can replace the type arguments required to invoke the constructor of a generic class with an empty set of type parameters (<>) as long as the compiler can infer the type arguments from the context. This pair of angle brackets is informally called the diamond.
Before Java 7 :
Map<String, List<String>> myMap = new HashMap<String, List<String>>();
Now you can do :
Map<String, List<String>> myMap = new HashMap<>();
Upvotes: 1
Reputation: 68715
Maybe because you are using Java7 compiler, which does not require params in the diamond operator.
Read more about it here: http://docs.oracle.com/javase/7/docs/technotes/guides/language/type-inference-generic-instance-creation.html
Upvotes: 1