Types of Java Statements


In this topic, you will learn about, Types of Java Statements.

Empty statement: An empty statement in Java is written as a single semicolon. The empty statement doesn’t do anything, but the syntax is occasionally useful.                        For example, you can use it to indicate an empty loop body of a for loop:

Labeled Statements: A labeled statement is simply a statement that has been given a name by prepending an identifier and a colon to it. Labels are used by the break and continue statements. For Example:

Expression Statements: Most statements in Java are expression statements. Java has seven types of expression statements.

  • Assignment
  • Pre-Increment
  • Pre-Decrement
  • Method Call
  • Allocation Expression

Selection statements: Selection statements are used to select one of the several control flows. There are three types of selection statements.

  •  if
  •  if … else
  • switch

Iteration Statements: Iteration statements are used to repeat one or more statements up to a given no. of time. There are three types of iteration statements.

  • while
  • do while
  • for

Jump Statements: Jump statements are used to pass the control to the beginning or end of the current block, or to a block, or to a labeled statement. Such labels must be in the same block and continue labels must be on an iteration statement. There are four types of jump statements.

  • break
  • continue
  • return
  • throws

Synchronization statement: These statements(e.g. synchronized) are used for handling issues with multi-threading.

Guarding Statements: These statements are used for the safe handling of code that may cause exceptions(such as division by zero). These statements use the keywords try, catch, and finally.

Comment below if you have queries related to the above topic Types of Java Statements.


Please enter your comment!
Please enter your name here