Interview Questions, Answers and Tutorials

Category: Control Flow Part-2

09.2 Control Flow

9.2 | Looping Statements Java supports four looping statements. for…statement for each…statement while…statement do-while…statement   for …statement   It executes a block of code a specified number of times.      For example – the code below prints numbers from 1 to 9.   for…each statement   It executes a block of code for each item in a collection or each element in an array.   For example – the code below prints all numbers in an array.     while…statement   It executes a block of code while or until the condition is true.   For example – The…