Gal
Gal

Reputation: 115

eclipse does not match constructor method call

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

Answers (2)

Alexis C.
Alexis C.

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

Juned Ahsan
Juned Ahsan

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

Related Questions