• Post Reply Bookmark Topic Watch Topic
  • New Topic

3 nested iterators over vectors Java  RSS feed

 
sarah sainy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 vectors like



Now i am iterating these 3 vectors like the following


When the if condition is satisfied the program is printing each candidate 4 times. Is it a problem with nested iterators..

When the if condition is satisfied the program is printing each candidate 4 times. Is it a problem with nested iterators..

More Clarification:
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand your problem exactly, but it might be because you are recreating the second and third iterators multiple times.
Try moving lines 10 and 17 to before line 2 and see if that solves your problem.

If not, then you might need to give us an example of the input and expected output. That might make your requirements a bit clearer.
 
sarah sainy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now each qualified candidates are printig 3 times
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, I didn't totally understand your first post, so it might be helpful if you could post an example showing what is in each vector and what output you are expecting from them.
 
sarah sainy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is working fine after removing middle iterator vector2. Because i am only checking for fn and ln that means vector 1 and vector 3.

But i in future i have to check all 3 fn, mn,ln.

Let me give more details:



How can i handle with 3 iterators and multiple conditions like the above
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!