This content originally appeared on DEV Community and was authored by V I N O T H
Key words in While loop:
In a while loop, the key Java keywords and concepts used are:
while – This keyword is used to start a while loop. It repeatedly executes a block of code as long as the given condition is true.
Loop Condition – The condition inside the parentheses (no1 < 10) determines if the loop should continue or stop.
Loop Body – The block of code inside {} runs repeatedly while the condition is true.
Loop Control Variable – A variable (no1 in your case) that changes inside the loop to eventually break the loop.
Increment/Decrement Statement – no1++ increases the loop variable to prevent an infinite loop.
Break Condition (Implicit) – The loop stops when the condition (no1 < 10) becomes false.
System.out.println – Used inside the loop to print output during each iteration.
Task 1:
package loopingDemo;
public class First_Looping {
public static void main(String[] args) {
// TODO Auto-generated method stub
int total=0;
int no1=0;
int no2=3;
while(no1<10) {
no1=no1+1;
total=no1*no2;
System.out.println(no1+"*"+no2+"="+total);
}
}
Output
1*3=3
2*3=6
3*3=9
4*3=12
5*3=15
6*3=18
7*3=21
8*3=24
9*3=27
10*3=30
Task 2:
package loopingDemo;
public class First_Looping {
public static void main(String[] args) {
int count=1;
while(count<=5) {
System.out.println("12345");
count++;
}
}
}
Output
12345
12345
12345
12345
12345
This content originally appeared on DEV Community and was authored by V I N O T H
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.

APA
MLA
V I N O T H | Sciencx (2025-02-04T16:19:37+00:00) While loop task. Retrieved from https://www.scien.cx/2025/02/04/while-loop-task/
" » While loop task." V I N O T H | Sciencx - Tuesday February 4, 2025, https://www.scien.cx/2025/02/04/while-loop-task/
HARVARDV I N O T H | Sciencx Tuesday February 4, 2025 » While loop task., viewed ,<https://www.scien.cx/2025/02/04/while-loop-task/>
VANCOUVERV I N O T H | Sciencx - » While loop task. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/04/while-loop-task/
CHICAGO" » While loop task." V I N O T H | Sciencx - Accessed . https://www.scien.cx/2025/02/04/while-loop-task/
IEEE" » While loop task." V I N O T H | Sciencx [Online]. Available: https://www.scien.cx/2025/02/04/while-loop-task/. [Accessed: ]
rf:citation » While loop task | V I N O T H | Sciencx | https://www.scien.cx/2025/02/04/while-loop-task/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.