HowToDoInJava

  • Java 8
  • Regex
  • Concurrency
  • Best Practices
  • Spring Boot
  • JUnit5
  • Interview Questions
  • Dark Mode

Types of Statements in Java

By Lokesh Gupta | Filed Under: Java Basics

A statement specifies an action in a Java program, such as assigning the sum of x and y to z, printing a message to the standard output, writing data to a file, etc.

Statements in Java can be broadly classified into three categories:

  • Declaration statement
  • Expression statement
  • Control flow statement

Declaration Statement

A declaration statement is used to declare a variable. For example,

int num;
int num2 = 100;
String str;

Expression Statement

An expression with a semicolon at the end is called an expression statement. For example,

/Increment and decrement expressions
num++;
++num;
num--;
--num;

//Assignment expressions
num = 100;
num *= 10;

//Method invocation expressions 
System.out.println("This is a statement");
someMethod(param1, param2);

Control Flow Statement

By default, all statements in a Java program are executed in the order they appear in the program. Sometimes you may want to execute a set of statements repeatedly for a number of times or as long as a particular condition is true.

All of these are possible in Java using control flow statements. If block, while loop and for loop statements are examples of control flow statements.

You can learn more about these stements in seperate tutorials in this blog.

Happy Learning !!

TwitterFacebookLinkedinRedditPocket

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Leave a Reply

This comment form is under antispam protection
This comment form is under antispam protection
  Subscribe  
Notify of

Search Tutorials

Java Tutorial

  • Java – Introduction
  • Java – JDK, JRE and JVM
  • Java – Naming Conventions
  • Java – ClassPath
  • Java – Variables
  • Java – Operators
  • Java – keywords
  • Java – Data Types
  • Java – Primitive Types
  • Java – Wrapper Classes
  • Java – Types of Statements
  • Java – Control Statements
  • Java – Labeled Statements
  • Java – String
  • Java – Create Class
  • Java – Immutable class
  • Java – main() Method
  • Java – Comments
  • Java – Pass-by-Value
  • Java – System Properties
  • Java – Static
  • Java – Static Import
  • Java – hashCode() and equals()
  • Java – this and super
  • Java – 32-bit vs. 64-bit
  • Java – java.exe vs javaw.exe
  • Java – Generate Bytecode
  • Java – Little-Endian vs Big-Endian
  • Java – Command Line Args
  • Java – Compare floats
  • Java – Recursion
  • Java – Pairs
  • Java – Tuples
  • Java – sun.misc.Unsafe
  • Java – UUID

Popular Tutorials

  • Java 8 Tutorial
  • Core Java Tutorial
  • Collections in Java
  • Java Concurrency
  • Spring Boot Tutorial
  • Spring AOP Tutorial
  • Spring MVC Tutorial
  • Spring Security Tutorial
  • Hibernate Tutorial
  • Python Tutorial
  • Jersey Tutorial
  • Maven Tutorial
  • Log4j Tutorial
  • Regex Tutorial

Meta Links

  • Advertise
  • Contact Us
  • Privacy policy
  • About Me

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2016 · HowToDoInjava.com · All Rights Reserved. | Sitemap

wpDiscuz