This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Skipping element addition in list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Skipping element addition in list" Watch "Skipping element addition in list" New topic

Skipping element addition in list

Skanda Raman
Ranch Hand

Joined: Mar 21, 2008
Posts: 205

I have a requirement to add elements from one list to another and during time if i encounter AB value second time, i have to add it in new list and not in current list, test. So I used the keyword continue if the values AB occurs. I am not getting the expected answer. My out put in list test should be as [9B, 9Y, AB, BC, BC]. Can any one please help me.

Rob Spoor

Joined: Oct 27, 2005
Posts: 20136

After you add "AB" for the first time, your second list will contain "AB" for the remainder of the loop. It will therefore skip both "BC" values as well.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Skipping element addition in list
It's not a secret anymore!