Pergunta

Eclipse used to autocomplete generics for me ... now it doesn't anymore and I can't figure out why.

I use to type

List<String> foo = new Arr

then hit Ctrl+Space and I would selecte ArrayList in the suggestions and the I would get

List<String> foo = new ArrayList<String>();

as a result.

But today eclipse is not total and I only get

List<String> foo = new ArrayList<>();

I have absolutely no idea what I might have done ... and I cant figure out how to bring back this nice behavior I got so much used to ...

Eclipse Version: Indigo Service Release 2 Build id: 20120216-1857

Any help appreciated :)

Thanks

Foi útil?

Solução

Second construct (without generics in initialization) is new feature of Java7 called diamond operator. Eclipse is reflecting this and if you are using JDK7 in your project, it is used in auto-complete. If you try switch to back to JDK6, auto-complete would be using old construct.

More info:
Oracle doc
Blog about diamond operator and Eclipse

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top