Java Statements

What is Java Statement?

  • In Java, a statement is a complete command of a program, and it is a line of code that expresses an action or a command to be executed by the computer. In other words, it is a single unit of execution that carries out a specific task or operation. Java is a structured programming language, and statements are used to control the flow of execution, perform operations, or define structures.
  • Each statement in Java typically ends with a semicolon (;). The sequence of statements makes up the Java program, and when the program is executed, the statements are executed one after another in the order they appear, unless the flow of execution is altered using control statements like loops and conditionals.
  • Java supports various types of statements, including but not limited to:
 Types of Statements:

Expression Statements:

 

Here are some examples of expression Statements:

1. Assignment Expression:
 
2. Increment/Decrement Expression:
 
3. Method Call Expression:
 
4. Method Invocation with a Return Value (although not used as a value here, the method is invoked for its side effects):
 
5. Object Creation Expression (creates a new object of a class):
 

 

Declaration Statements:

 

For example:
 

 

For example:
 

 

For example:
 

Control Statements:

 

 

 

 
 

 

Visited 1 times, 1 visit(s) today

Comments are closed.

Close