Java Expression statements

ww‮ruttual.w‬i.com
Java Expression statements

In Java, an expression statement is a statement that consists of an expression followed by a semicolon. Expression statements are used to execute an expression and produce a side effect, such as assigning a value to a variable or calling a method.

Here are some examples of expression statements in Java:

int x = 1; // assignment expression statement
x++; // post-increment expression statement
System.out.println("Hello, World!"); // method call expression statement

In the first example, an assignment expression statement is used to assign the value 1 to the variable x. In the second example, a post-increment expression statement is used to increment the value of x by 1. In the third example, a method call expression statement is used to call the println() method of the System.out object and print the string "Hello, World!" to the console.

You can use expression statements to execute any valid expression in Java and produce a side effect. Just follow the expression with a semicolon to create an expression statement.

Created Time:2017-11-03 15:57:10  Author:lautturi