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

Cyber Security

In this article, we are going to examine real-world logic bombs. Also, we are going to create one with Python for seeing how to...

Cyber Security

Welcome to the second tutorial on networks for hackers. We are going to learn network types and weaknesses and strengths of networks in this...

Programming

In this tutorial, we going to learn file handling with Python. At the end of the article, you will be ready to work with...

Cyber Security

In this article, we going to learn how networking works and simple terms in networking. Also, we are going to learn simple network attacks....