Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

I had uploaded in basic things

Rating
-
Sold
-
Pages
12
Uploaded on
09-06-2025
Written in
2024/2025

Basic things like control structure, class, break, continue, return, loops and syntax, condition statement

Institution
Course

Content preview

Control Statements

The control statements are used to control the flow of execution of the program. Java contains the following
Types of control statements:
1) Selection Statements / Decision making statements: if, if-else, switch.
2) Repetition Statements / Looping Statements: while, do-while, for.
3) Branching Statements / Jumping Statements: break, continue, and return.

Selection Statements / Decision making statements: As the name suggests, decision-making statements decide
which statement to execute and when. Decision making statements evaluate the Boolean expression and control
the program flow depending upon the result of the condition provided.

There are two types of decision making statements in Java, i.e.
1. If statement
2. switch statement.

1) If Statement: In Java, the "if" statement is used to evaluate a condition. The control of the program is diverted
depending upon the specific condition. The condition of the If statement gives a Boolean value, either true or false.
In Java, there are four types of if statements given below.
1. Simple if statement
2. if-else statement
3. Nested if-else statement
4.else if ladder

SIMPLE IF STATMENT Syntax:
If(expression)
{
Statements;
}

Java program to illustrate If statement

class IfDemo
{
public static void main(String args[])
{
int i = 10;
if (i > 15) {
System.out.println("10 is less than 15");}
System.out.println("I am Not in if");
}
}
Output: I am Not in if

, THE IF...ELSE STATEMENT
The if. ..else statement is an extension of the simple if statement.

Syntax

if(test expression)
{
True block statement(s)
}
Else
{
False block statement(s)
}
Statement x;

If the test expression is true, then the true-block statement (s) immediately following the if statement, are executed;
otherwise, the false -block statement (s) are executed. In either case, either true– block or false – block will be
executed, not both.

Java program to illustrate if-else statement

class IfElseDemo {
public static void main(String args[])
{
int i = 10;
if (i < 15)
System.out.println("i is smaller than 15");
Else
System.out.println("i is greater than 15");
}
}
Output: i is smaller than 15

NESTING O IF ELSE STATEMENTS

When a series of decisions are involved, we may have to use more than one if…else statement in nested form

Written for

Institution
Course

Document information

Uploaded on
June 9, 2025
Number of pages
12
Written in
2024/2025
Type
OTHER
Person
Unknown

Subjects

$7.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Kusuma

Get to know the seller

Seller avatar
Kusuma Mandavya first grade college
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
10 months
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions