numapples apples getnumapples ()for (int numapplesx++eatapple (apples getapple ( ))spitoutcore ()in the java example abovethe loop variable was declared as int before each iterationthe loop tests the condition numapplesand executes the loop body only if this is true finallyat the end of each iteration the loop uses the statement +to increment the loop variable before again testing the condition incidentallysince java also includes for-each loopwhich we discuss in section do-while loops java has yet another kind of loop besides the for loop and the standard while loop--the do-while loop the former loops tests condition before performing an iteration of the loop bodythe do-while loop tests condition after the loop body the syntax for do-while loop is as shown belowdo loop_statement while (boolean_expagainthe loop body statementloop_statementcan be single statement or block of statementsand the conditionalboolean_expmust be boolean expression in do-while loopwe repeat the loop body for as long as the condition is true each time it is evaluated considerfor examplethat we want to prompt the user for input and then do something useful with that input (we discuss java input and output in more detail in section possible conditionin this casefor exiting the loop is when the user enters an empty string howevereven in this casewe may want to handle