Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics question--Bit complicated??

 
prashanth kumar
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have this question regarding generics.
Can anybody explain me why the options 4 and 6[i know abt this option]are correct?

Many Thanks

 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Option 4 is correct because if you removed lines 2 and 3, you are just adding a new entry to the map containing a String for key, and ArrayList for value.

Option 6 will work because there is no requirement in a general map that the keys be mutually Comparable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic