For loop problem?
<p>I have a method to compare two list of objects.</p>

<p>The objects are unique in both lists.</p>

<p>I doing it with 2 level nested for loops</p>

<p>I want to terminate the inner for loop's remaining cycles if two objects match correctly.</p>

<p>Is it possible to terminate the remaining iteration of a for loop in Java?!</p>

<p>Thanks</p>

<p><strong>The Sample Code:</strong></p>

<p>public class NestedForLoops {</p>

<pre><code>/**
 * @param args
 */
public static void main(String[] args) {
    String one = "abcdefgh";
    String two = "ijkhmnop";
    System.out.println(nestedForLoop(one, two));

}

public static String nestedForLoop(String one, String two)
{
    String res = "";
    for(int i = 0; i &lt; one.length(); i++)
    {
        for(int j = 0; j &lt; two.length(); j++)
        {
            if(one.charAt(i) == two.charAt(j)){
                System.out.println(i + "   " + j);
                res += one.charAt(i);
                continue;
            }
        }
    }
    return res;
}
</code></pre>

<p>}</p>
