3.4. Simple Assignment Operator =
The assignment statement has the following syntax:
<variable> = <expression>
which can be read as “the destination, <variable>, gets the value of the source, <expression>”. The previous value of the destination variable is overwritten by the assignment operator =.
The destination <variable> and the source <expression> must be type compatible. The destination variable must also have been declared. Since variables can store either primitive data values or object references, <expression> evaluates to either a primitive data value or an object reference.
Assigning Primitive Values
The following examples illustrate assignment of primitive values:
int j, k; j = 10; // j gets the value 10. j = 5; // j gets the value ...
Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.