Do While Loop Example - Java Examples - Java Program Sample Source Code PDF
Do While Loop Example - Java Examples - Java Program Sample Source Code PDF
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
/*
Do While loop Example
This Java Example shows how to use do while loop to iterate in Java program.
*/
/*
* Do while loop executes statment until certain condition become false.
* Syntax of do while loop is
*
* do
* <loop body>
* while(<condition>);
*
* where <condition> is a boolean expression.
*
* Please not that the condition is evaluated after executing the loop body.
* So loop will be executed at least once even if the condition is false.
*/
int i =0;
do
{
System. out. println("i is : " + i );
i++;
}
}
/*
Output would be
i is : 0
39.
40.
41.
42.
43.
Like
i is : 1
i is : 2
i is : 3
i is : 4
*/
14
Tweet
36
Advertisement:
Subscribe
25 Comments
javaex
Recommend 8
Share
Login
Sort by Best
Sahar Css
4 years ago
Reply
2 years ago
Reply
nej_jen
4 years ago
Output:
i and j: 0 10
i and j: 1 9
i and j: 2 8
i and j: 3 7
i and j: 4 6
May i know the complete code for this output??plssssss..
6
Reply
4 years ago
class code
{
public static void main(String[] args)
{
int i=0,j=10;
do{
System.out.println("The value of i and j :"+i+ "\t" +j );
i++;
j--;
}while(i<5&&j>5);
}
}
12
Reply
Jerry Castillo
4 years ago
12
Reply
10 months ago
int i =0;
do{
System.out.println( "Hello");
i++;
}while( i <5 );
0
Reply
Anonymous
6 years ago
Reply
Axel Driege
a year ago
Can i plz have the code for this output i can't find it.
output;
enter a word:
example
example
exampl
examp
exam
exa
ex
e
ex
exa
exam
examp
exampl
example
see more
Reply
Anonymous
6 years ago
Reply
10 months ago
Reply
jenelyn olila
7 months ago
pls help me,this is my final exam in java and its hard for me to do this,,, i
hope somebody could answer my question...how to make a 3 programs with
password..note:the password is included in the code not in the dialog
box.tnx a lot... i want to know what is the code of this...tnx a lot.
0
Reply
refiloe
8 months ago
Reply
Elman Manalo
8 months ago
Reply
Cheii Chu
9 months ago
do you know how to get this ? using do and while loop in java?
Make a program that will ask user to enter 10
numbers. Display only all the even inputs by the user. Use modulo operation
in
this problem. The program must be able to repeat the process if he/she
wants to..
0
Reply
Cheii Chu
9 months ago
Reply
9 months ago
may i know the code for this output please....using while looping.
11111
11111
11111
11111
11111
11111
0
Reply
Victoria aguas
a year ago
1
2
3
4
5
6
7
8
9
19
Boom!
may i know the code for that output?
0
Reply
10 months ago
Reply
maria
2 years ago
Reply
10 months ago
int i = 3;
do{
System.out.println(i);
i--;
}while( i * 2) ;
}while( i * 2) ;
0
Reply
Subscribe
Privacy