0

I want to specify this type:

Map<String,Map<String,String>> blah = null;

But Eclipse refuses this. I am not sure if it is Eclipse or the Java parser.

I had similar issues when trying to write my own java parser at study times: ">>" was regarded as the shift operator.

What's going on here?

Edit: java works for this.

1
  • 3
    Why not actually specify what happens instead "Eclipse refuses this". If I paste that code in my eclipse, I see no problems. Commented Mar 23, 2011 at 11:09

2 Answers 2

1

It could be because your eclipse is set up to use a compiler version for java 1.4 which doesn't have generics.

Does it work if you just do

Map<String,String> map = null;

EDIT: Setting in eclipse enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

No problem for me as expexted...

Indeed you can for sure define nested generic like you was doing

Map<String,Map<String,String>> blah = null;

Event doing this will not cause problems

Map<String,Map<String,Map<String,String>>> blah = null;

It is not a problem of nested generic (Java support this feature), it is a problem of generic support. Be sure to have the right settings for your compiler in Eclipse, you have to set at least java 1.5 for enabling generics. (Windows->Preferences->Java-Compiler and then check the version).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.