Google Analytics

Sunday, November 20, 2016

Java for loop escape one loop

To avoid an iteration use CONTINUE key word. Presentation

for (Vehicle printVehicle : getParkedVehicles()) {
if("VAN".equals(printVehicle.getVehicleType().toUpperCase())){
vanCount++;
if(vanCount == 2){
vanCount = 0;
continue;//SKip the iteration related to additional Van record
}
}
}

No comments:

Post a Comment