私はオブジェクトの2つのリストを比較する方法を持っています。ネストされたループから抜け出すには?
オブジェクトは両方のリストで一意です。
私は2つのオブジェクトが正しく一致した場合にループの残りのサイクルのためのインナーを終了したいループ
ためにネストされた2レベルでそれをやって。
forループの残りの繰り返しをJavaで終了することはできますか?
おかげ
サンプルコード:インナー
public class NestedForLoops {
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 < one.length(); i++)
{
for(int j = 0; j < two.length(); j++)
{
if(one.charAt(i) == two.charAt(j)){
System.out.println(i + " " + j);
res += one.charAt(i);
continue;
}
}
}
return res;
}
}
心? – mauris
@ thephpdeveloper:私は答えを得た。私は休憩はstatmetnsの場合にのみ使用できると思った。私はそれに試してみたはずです。さて、私はどのように継続して役に立つのか疑問に思う。 –