WEBVTT

00:00.000 --> 00:06.000
Control structure, loops.

00:06.000 --> 00:11.000
In this video, we will understand the importance of loops in Java programming.

00:11.000 --> 00:16.000
Identify the three main types of loops, four, while, and do while.

00:16.000 --> 00:20.000
Differentiate when to use each type of loop.

00:20.000 --> 00:26.000
Apply loops in simple coding problems and real-life examples.

00:26.000 --> 00:30.000
Have you ever repeated the same action like clapping four times?

00:30.000 --> 00:31.000
That's repetition.

00:31.000 --> 00:35.000
In programming, loops handle it automatically.

00:35.000 --> 00:40.000
Without loops, we type the same code again and again, line after line.

00:40.000 --> 00:47.000
It's repetitive, slow, and quickly becomes frustrating for any programmer.

00:47.000 --> 00:51.000
With loops, one short program can repeat tasks automatically,

00:51.000 --> 00:56.000
less typing, faster results, and coding becomes much easier.

00:56.000 --> 00:59.000
There are three types of loops.

00:59.000 --> 01:05.000
For loop, while loop, and do while loop, let's explore them one by one.

01:05.000 --> 01:10.000
The four loop is used when we already know how many times to repeat a task.

01:10.000 --> 01:16.000
Its structure is four with three parts, initialization, condition, and update.

01:17.000 --> 01:21.000
For example, we can use it to print numbers from one to ten.

01:23.000 --> 01:28.000
A while loop is used when we don't know exactly how many times to repeat.

01:28.000 --> 01:34.000
For example, if the condition is set to three, the loop runs three times and prints three claps.

01:34.000 --> 01:39.000
If we set it to two, it runs twice and prints two claps.

01:39.000 --> 01:44.000
The loop continues like this until the condition becomes zero, then it stops.

01:44.000 --> 01:47.000
That's how the while loop controls repetition.

01:52.000 --> 01:58.000
In a do while loop, the program shows the options first and then checks the condition.

01:58.000 --> 02:03.000
If no exit condition is applied, the program shows the options again.

02:03.000 --> 02:07.000
If a condition is applied, the program runs according to it.

02:07.000 --> 02:12.000
That means the loop always runs at least once, even if the condition is false.

