Connect with us

Hi, what are you looking for?

Programming

Control Structers In Java

Control Structers In Java
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!

Click to comment

Leave a Reply

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

You May Also Like

Programming

This article was created for those who want to use functional programming in their career or who are learning new programming paradigms. We will...

Programming

Functions are pieces of code that combine the integrity of the code used to perform a task into a single structure. If you are...

Programming

Computers can solve an event in different ways, we call these ways algorithms, each algorithm works differently from the others and has different processing...

Data Science

SQL (Structured Query Language) is one of the most used tools by data scientists, data analysts, and data engineers. Almost all companies use a...