Java Programming Tutorial Index

Java Fundamentals

The Java Assignment Operators are used when you want to assign a value to the expression. The assignment operator denoted by the single equal sign =.

In a Java assignment statement, any expression can be on the right side and the left side must be a variable name. For example, this does not mean that "a" is equal to "b", instead, it means assigning the value of 'b' to 'a'. It is as follows:


variable = expression;


int a = 6;
float b = 6.8F;

Java also has the facility of chain assignment operators, where we can specify a single value for multiple variables.


public class ChainAssign {
    public static void main(String args[]) {
        int a, b, c;
        a = b = c = 100; // set a, b, and c to 100
        System.out.println("a = " + a);
        System.out.println("b = " + b);
        System.out.println("c = " + c);


a = 100
b = 100
c = 100

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram