java - For loop inside of for loop not executing -
the second loop executing first number(999) in first loop. trying have second loop execute each number 999-101 in second.
int num1 = 999; int num2 = 999; int test1 = 0; string test = ""; for(; num1!=110; num1--){ system.out.println("--------"+num1); for(; num2!=100; num2--){ system.out.println("++++++++"+num2); test1 = num1*num2; test = string.valueof(test1); //system.out.println("checkpoint 2"+"--------------"+test1); if(test.length()==5){ if(test.charat(0)==test.charat(5) && test.charat(1)==test.charat(4) && test.charat(2)==test.charat(3)){ system.out.println("checkpoint 1"+"----------"+test); break; } else{ //system.out.println("fail 1"); } } } }
after first run of second loop num2
has value 100 statement num2!=100
false
, not execute. set value num2 execute each loop:
for(num2=999; num2!=100; num2--) { ... }
Comments
Post a Comment