123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Types Of Control Statement In Java

Profile Picture
By Author: Infocampus
Total Articles: 33
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

A program executes from starting to ending except when we use control statements.Through control statement we control the order of execution of the program, on the basis of some logic and values.

In Java, We can divide the control statements into the following three categories:
1) Selection Statements
2) Iteration Statements
3) Jump Statements
Selection Statements :

Selection statements allow us to control the flow of program execution on the basis of the outcome of an expression or state of a variable java training center bangalore known during runtime.

We can divide it in-
- if statements
- if-else statements
- if-else-if statements
- switch statements

The if statements :
if statement only executes when the specified condition is true. If the condition is false and there is not else keyword then the if statement will be skipped and execution continues with the rest of the program. The condition is an expression that returns a boolean value.
The if-else statements:

In if-else statements, if the specified condition ...
... in the if statement is true then if block will get executed and else part will skipped . Java/j2ee classes bangalore if the specified condition in if block is false then if block will get skipped and else block will get executed.

The if-else-if statements:

Also known as ladder if -else. This statement following the else keyword can be another if or if-else statement.

For example :

if(condition)
statements;
else if (condition)
statements;
else if(condition)
statement;
else
statements;

Whenever the condition is true, the associated statement will be executed and the remaining conditions will be skipped. If none of the conditions are true then the else block will get executed .

The Switch Statements

The switch statement is a multi-way branch statement . Advanced java training in bangalore The switch statement of Java is defines multiple paths of execution of a program. It provides a good alternative than a large series of if-else-if statements.

Iteration Statements

Repeating the same code part multiple times until a specified condition is satisfied is called iteration. Iteration statements execute the same set of instructions until a termination condition is met.

Java provides the following loop for iteration statements:
1) for loop
2) while loop
3) do-while loop
4) for each loop
The for loop :

A for loop executes a block ofstatements multiple times till the boolean condition evaluates to true . Java course in bangalore A for loop is a combination of the three elements initialization statement, boolean expression and increment or decrement statement.

The while loop :

It executes a block of statements while a condition is true. The condition must return a boolean value. In while loop initial condition is unknown.

The do-while loop :

The only difference between a while and a do-while loop is that in do-while loop first executes the statements then check the condition . If the condition is false then also execute the statement once.
In while loop first check the condition then execute the block of statement.if condition false then never execute the block. Best core java training in bangalore

Labeled Break Statement: This is used for when we want to jump the program control out of nested loops or multiple loops.

Unlabeled Break Statement: This is used to jump program control out of the specific loop on the specific condition.

Continue Statement :
The continue statement is used when we want to continue running the loop with the next iteration and want to skip the rest of the statements of the body for the current iteration.

The continue statement has the two forms:
1) Labeled Continue Statement
2) Unlabeled Continue Statement
Labeled Continue Statement: java training center bangalore This statement skips the current iteration of the loop with the specified label.

Unlabeled Continue Statement: This statement skips the current iteration of the innermost for , while and do-while loop.

This is the brief description about the control statement. To get more knowledge on Core & Advanced java attend java training in Infocampus Software Training Institute.

Author : Infocampus provides best java training in bangalore with the real time project and 100% job support . Fully practical session is available for java/j2ee classes . Every weekend free demo classes are available for Core & Advanced java.
Infocampus provides best core java training in lesser fees. Learn serialisation, packages, multithreading , struts framework etc in Advanced java training. Java course is provided by the more than 10 years experienced trainers.
To book the free demo class call at : 9738001024 or to get the syllabus of java training enquire at : http://www.infocampus.co.in/java-training-bangalore.html

Total Views: 443Word Count: 826See All articles From Author

Add Comment

Computer Programming Articles

1. Which Institute Is Best For Coding And Programming In Bhopal?
Author: Shankar Singh

2. Top 9 Benefits Of Custom Mobile Application Development
Author: Byteahead

3. Top 10 Creative Business Ideas For Entrepreneurs
Author: Byteahead

4. Top 10 Apps Like Tiktok Everyone Should Check Out
Author: Byteahead

5. Is The Apple Watch Series 7 Worth It For Seniors?
Author: Ashish

6. The Ultimate Guide To Ebay Product Listing Services: Elevate Your Online Store
Author: rachelvandereg

7. Which Are The Best Java Coding Classes In Bhopal?
Author: Shankar Singh

8. Warehouse Management In Zambia: Essential Features To Look For
Author: Doris Rose

9. Ecommerce Web Design And Development In Melbourne With The Merchant Buddy
Author: themerchantbuddy

10. Why Website Maintenance Is Crucial For Business Success
Author: Yogendra Shinde

11. Boost Your Business With Smart Invoice Pos Software In Zambia
Author: Cecilia Robert

12. How Stablecoin Development Ensures Stability And Security?
Author: Michael noah

13. Công Cụ Tính Chiều Cao Chuẩn Từ Minbin Tool: Đo Lường Và Cải Thiện Chiều Cao Hiệu Quả
Author: KenJi123

14. How To Make A Courier App For Courier Delivery And Tracking Service
Author: Deorwine Infotech

15. Reputation Management In The Digital Age: Protecting And Enhancing Your Law Firm’s Image
Author: jamewilliams

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: