• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating in a collection (LIST or MAP)

 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers ,

I'm getting this [[shipmentId=20390, facilityId=10070, shipGroupSeqId=00001]] collection from a service , can you please tell me how to iterate throw this collection . I need to get the shipmentid .
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is that structure? A String? A List of Lists? A List of arrays? A List of Maps?
 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Rob,

Even I'm also trying to get the structure .
I think its a list in list structure ,list thought it would be a list in list with a map as element.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
karimkhan pathan wrote: it would be a list in list with a map as element.

probably it is not! . Map elements always display surrounding by "{}" . so first find out what types are that by using getClass() . i think it should be *list of list of some thing* . if yes just iterate through by using 2 for loops.
 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Seetharaman ,

your correct ,its not a map its a list in list only .

Thanks a lot ranchers ..
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Until you find out it's going to be difficult, so you'll need to analyze first. Using getClass(), instanceof and casting you can already find out a lot. A recursive call may be quite useful:
The indentation is there to make it easier for you to see the full structure. The initial call uses an indent of "".
 
karimkhan pathan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob , It will help me .
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic