troubleshooting Question

IF statement inside nested FOR loops - it beaks the loops

Avatar of Ali B
Ali BFlag for Australia asked on
Java
21 Comments3 Solutions284 ViewsLast Modified:
Here's the problem in the next code, the IF statment breaks the outer loop once the condition is not true. I don't know where's the error!
what should I do to make the two loops continue looping even if they didn't pass the IF statement.

A sample of my code:
//--------------------------------------------------------------------------------------------------

for(int i=0; i<5; i++){
     for(int j=0; j<30; j++){

                if (   listA[i] == listB[j]   ) {        // both are int.
                   
                    counter++;                     // this not my original but something simplified
                }
            }
        }
//-----------------------------------------------end-----------------------------------------------
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros