for(int i = 1;i < 3; i++){ if(i == 1){ //the code did something here } if(i == 2){ //the code did something here } }