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.

You May Also Like

News

What is LaMDA? The LaMDA is an AI (neural network) developed to realize natural conversations with humans by extracting information from a large amount...

Programming

In this article, we will create a simple timer app for beginners with Swift and SwiftUI. Step 1: Create a Header First, we will...

Programming

Swift optionals can be a bit confusing, in this article we’ll go into detail about optionals. We will look at how they can be...

News

According to a study from Dartmouth College, Dartmouth’s Tuck School of Business, and Indiana University, artificial intelligence systems can be trained to produce human-like...