Control Structers In Java

In this tutorial, we going to look at the control structures in Java programming, this tutorial consists of a conditional statement and for, while loop statements.

Control Structures In Java

We will first look at loop expressions, these are the units that enable the program to produce different outputs. After that, we going to create conditional statements.

a = 1;
while(10 > s)
{
   a++;
   System.out.println(a);
}

In the example above, as long as a is less than 10, a will print and increase on the screen, when a is 10 the loop will end and the program will finish.

for(a = 10; a > 100; a++) 
{
   System.out.println(a);
}

In the code block here, the number a is assigned as 10, and if the condition a is less than 100, then 1 value is added to the loop when each loop is started, you can change it, and then the loop is terminated when the condition part is false.

for(int i in 10)
{
   System.out.println(i);
}

The above code block is for each block. With this loop, you can navigate within a string or set a loop according to the value you assign without specifying a limit. The “in” statement indicates that the left value is inside the right value, and the loop continues.

if(condition)
{
   // Code
}
else if(condition)
{
   // Code
}
else
{
   // Code
}

In the above structure, there is a code block that produces different outputs according to the condition. With this code block, you can produce different results depending on the situation.

CONGRATULATIONS YOU FINISHED CONTROL STRUCTURES IN JAVA!

Leave a Reply

Your email address will not be published. Required fields are marked *