I have a parent Arraylist (ara) which contains a list of child ArrayLists (ar)!
I'm wondering what the syntax is that will allow me to update one of the child objects (Token class) within these Arraylists!
I have labeled some of the areas where the lists are being built with "<<<<<<<" and the very last one labeled "<<<<<<problem" is where i'm trying to update a child object within these ArrayLists!
I would think it should look something like this: ara[i].set(j,tarj), but now realize that i would have to use an regular array of ArrayLists for this syntax, but i'm assuming there is a syntax for this particular scenario?
Originally posted by bob connolly: Got it Dave! very cool!
Note that that will only put the nshr field from the object referenced by tarj into the ArrayList. The rest of the Token will completely disappear. If you need to keep the Token object intact, but just replace the nshr field, then you should probably do something like this:
Notice that I've split up your single line of code above into several lines. Personally, I think this helps with readability. Also, if you train yourself to think along these lines, I think you will be able to figure this out on your own when similar situations arise in the future.
I have one last comment on your choice of variable names. What does "nshr" mean? Personally, I dislike cryptic abbreviations like this. It would probably help you be able to read your own code if you use more descriptive names for your variables. Will you be able to read this code if you have to come back to it in 2 weeks? How about in 2 months? Or a year?