aspose file tools*
The moose likes Beginning Java and the fly likes Iterating in a collection (LIST or MAP) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Iterating in a collection (LIST or MAP)" Watch "Iterating in a collection (LIST or MAP)" New topic
Author

Iterating in a collection (LIST or MAP)

karimkhan pathan
Ranch Hand

Joined: Jul 14, 2008
Posts: 86
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 .


karim
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

What is that structure? A String? A List of Lists? A List of arrays? A List of Maps?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karimkhan pathan
Ranch Hand

Joined: Jul 14, 2008
Posts: 86
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Jul 14, 2008
Posts: 86
Hi Seetharaman ,

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

Thanks a lot ranchers ..
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

You are welcome
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

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

Joined: Jul 14, 2008
Posts: 86
Thanks Rob , It will help me .
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterating in a collection (LIST or MAP)