Skip to main content

Posts

Showing posts with the label do-while

Loops

Loops:- Loops are used for iterating similar statements for multiple times. Types:- 1.      For loop 2.      While loop 3.      Do-while loop 4.      For-each loop For loop:- Syntax of for loop:- for(initialization;condition;counter) Statement1; for(initialization;condition;counter) { Statement1; Statement1; } For loop must contain two semicolons inside parenthesis. for loop contains three parts inside parenthesis first part contain initialization ,second part contain condition and third part contain counterpart. control first go for initialization then go for condition if the given condition is true then go for body execution after that control go for counter then again go for condition if condition is true then repeated and so on.   Example1:-TestLoop.java class TestLoop { public static void main(String[]args) { int i; System.out.println("D...