Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on subMap() in NavigableMap

 
Kir Swa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source of the code: ExamLab


Line 1:NavigableMap ns=nv.subMap(0, true, 6, true);
Line 2:NavigableMap ns=nv.subMap(1, true, 4, true).subMap(0, true, 3, true);

Both method arguments are out of bounds, but Why iam getting Exception when inserting Line2 but not Line1?

And the Similar problem with subSet()

Thanks in advance

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code tag please.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kir Swa wrote:
NavigableMap ns=nv.subMap(1, true, 4, true).subMap(0, true, 3, true);


first sunMap invocation makes fromKey index to 1 there is no 0 index and now the second subMap access the 0 from key index which is not available, hence exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic