• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with ArrayList.  RSS feed

 
Shiny Suresh
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have this ArrayList List<CssValList>.
CssValList is a bean which has the fields attrNm, attrvalNm etc..
Now I need to iterate through this ArrayList List<CssValList> and extract only the attrNm from it and assign to another List of strings. How do I do that? Any help would be appreciated.

Thanks,
Shiny Suresh.

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shiny Suresh wrote:
Now I need to iterate through this ArrayList List<CssValList> and extract only the attrNm from it and assign to another List of strings. How do I do that?


What part are you having trouble with?

  • Iterating over a List?
  • Getting the attrNm value from one of your CssValList beans?
  • Putting a value into a List?


  • Those are the only things you have to do, so if you know how to do all of them, then you know how to solve your problem.
     
    Shiny Suresh
    Ranch Hand
    Posts: 31
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator



    I have written something like this. Could you please help me with this? Thanks for your prompt response.

    Shiny Suresh.
     
    Jeff Verdegan
    Bartender
    Posts: 6109
    6
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Once again: What specific problems are you having? Most people here won't be inclined to try to read your code and try to guess what problems you're having with it.

     
    Gaurav Raje
    Ranch Hand
    Posts: 136
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Shiny Suresh wrote:


    I have written something like this. Could you please help me with this? Thanks for your prompt response.

    Shiny Suresh.

    For starters, you might want to use the enhanced for loop instead of the regaular i ++ kinds i think. Otherwise, you are only adding empty cssvallists to the new list

     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!