0

Java (TripleForLoopCode)

is this code run like this?(comment) https://code.sololearn.com/cS2gapxpT4ro

9th Jun 2019, 7:38 AM
Tzion
Tzion - avatar
5 Answers
+ 2
Rael I'm just showing you the order how 2 nested the loops run inside an outer loop if you replace your if statement with the following you can see what's happening System.out.println(arr1[i]+" "+arr2[x]+" "+arr1[i] +" "+arr3[p]);
9th Jun 2019, 9:07 AM
D_Stark
D_Stark - avatar
+ 3
3 loops like yours runs like this I will call each loop A B C and say it runs 2 times. A B CC B CC Back to Outer Loop A B CC B CC
9th Jun 2019, 8:44 AM
D_Stark
D_Stark - avatar
+ 1
ps your code does 216 loops with if check if you divide your if expression: for(int i .. for(int x .. if(arr1[i] == arr2[x]) for(int p .. if(arr1[i] == arr3[p]) System.out .. then it do 48 loops with same result
9th Jun 2019, 11:35 AM
zemiak
+ 1
D_Stark yeah i so same as i comment,thanks a lot!
9th Jun 2019, 1:15 PM
Tzion
Tzion - avatar
0
D_Stark what means? 😂
9th Jun 2019, 8:46 AM
Tzion
Tzion - avatar