1

I have this declaration/initiation written for Java JDK 1.6

Map<String, <? extends List<?>>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

The error happens at the first comma. The error message is

Type mismatch: cannot convert from HashMap<String,ArrayList<String[]>> to Map<String,List>

Why doesn't this compile?

1
  • Oops, this compiled for me (removed previous post as I copied the wrong code) Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();. Commented Jul 14, 2011 at 5:42

2 Answers 2

3

You've got too many angle brackets. Try this:

Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

This compiles for me.

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

Comments

0

Are you sure of this?

This, similar code, compiles OK for me:

Map<String, ? extends List<?>> groupThemTogether = new HashMap<String, ArrayList<String[]>>();

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.