Java Statements

Java Statements

A statement in Java is a complete instruction that tells the computer to perform an action. A Java program is made up of many statements that execute in sequence.

Every executable Java statement ends with a semicolon ( ; ).


✔ Types of Java Statements

Java statements can be categorized into:

  1. Declaration Statements

  2. Expression Statements

  3. Selection (Control Flow) Statements

  4. Looping (Iteration) Statements

  5. Jump Statements

  6. Block Statements

Let’s understand each one 👇


1️⃣ Declaration Statements

Used to declare variables.



 


2️⃣ Expression Statements

These perform actions like assignment, method calls, increments, etc.

Examples:



 


3️⃣ Selection (Decision-Making) Statements

Used to make decisions based on conditions.

Statement Type Example
if Runs block if condition is true
if-else Runs alternative block if false
switch-case Multiple conditional branches

Example:



 


4️⃣ Looping (Iteration) Statements

Used to repeat actions multiple times.

Loop Type Meaning
for Runs for a defined number of times
while Runs while condition is true
do-while Executes at least once

Example:



 


5️⃣ Jump Statements

Used to change normal flow.

Statement Purpose
break Exit a loop or switch
continue Skip current loop iteration
return Exit method and optionally return a value

Example:



 


6️⃣ Block Statement

A block statement is a group of statements inside curly braces { }.



 

Blocks are used in:

  • classes

  • methods

  • loops

  • if conditions


🧠 Example Program Using Different Statements


 


⭐ Summary

Type Example
Declaration int x = 5;
Expression x++;
Selection if, switch
Loop for, while
Jump break, continue, return
Block { ... }

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

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