Site icon TestingDocs.com

Java Assignment Statement

Overview

In this tutorial, we will learn about Java Assignment Statement. We
can assign or give value to a variable using the assignment statement.

Syntax

The general syntax for assigning a value to a variable is as follows:

variable_name = value;

We can also assign value to a variable as part of the declaration. This is known as variable initialization. The syntax for the variable initialization is:

Datatype variable_name = value;

Examples

To assign a value of 72 to a variable named length:

// assign a value to the variable

length = 72;

For example, to initialize a variable width to 6.2:

//declare and initialize the variable

float width = 6.2;

Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/java/

Exit mobile version