To sum up, the assignment syntax in Java is as follows :

we specify the name of the variable, followed by the equals symbol (=),

followed by an expression, valid in Java.

This expression can be something elementary,

such as a literal value, like here.

It can also be much more complex, like here.

We will come back to expressions and further discuss them later.

The critical point is that the type of the value

computed by the expression

must be the same as the variable's one

Another syntactic detail :

do not forget the semicolon (;) at the end of the assignment instruction.

Now, let us go back

to the comparison between the mathematical equality and the assignment.

Both use the equals sign (=)

and the notion of variables.

Self-evidently, if, in mathematics, we write such an expression,

we signify that the variables a and b

will always have the same value over time.

On the other hand, the assignment in programming

is a different mechanism entierely; it is dynamic

and will thus depend on time.

Let us take a concrete example.

Let us imagine that a contains the value 1 and b contains the value 2.

If we execute now this first instruction,

we start by, as we have just seen,

evaluating the expression on the right-hand side of the assignment;

this will give us the value 2.

Then, we will store this value, this 2, inside the variable a

which leads us to this result.

Now, let us analyze the second instruction

with the exact same starting conditions,

that is a containing 1 and b containing 2.

Now, if we execute this instruction,

as before, we start by evaluating what stands on the right side of the assignment,

returning 1.

Then, we store this 1 inside b, which results in this situation.

Thus, we see that in programming, in both cases,

a and b have the same value

but these values are not the same over time.

Moreover, if, at some point, one of the two variables is modified,

the other remains unaffected.

For example, if a is then modified to 3,

b will keep its value, for example 1, in the second assignment.

Another example : if, in mathematics,

we write such a relation, it means that a and b will awlays

verify this relation, regardless of the time.

However, if we write the exact same thing in programming,

we will see that the result for a and b is decidedly different.

Thus, here, we start by executing this instruction,

resulting in the variable a contaning 5.

Then, we execute this assignment instruction.

As we have seen before, we will start by evaluating "a + 1",

returning 6 and storing this 6 inside the variable b,

resulting in this situation.

At this point, a and b indeed verify this relation.

However, if we move on to the next instruction,

we will modify a's value to 2.

We now see that the relation is not verfied anymore.

Due to what we have just seen,

it is licit, in programing to resort to similar formulations.

By the way, this formulation, which you will often encounter,

along our examples is particularly useful.

Now, what happens if we execute such an instruction ?

Let us start with a concrete example, with a initialized to 1.

As we have just seen,

we start by evaluating this part of the assignement, returning 2.

In a second time, we will store this 2 inside a,

leading to this result.

Thus, when we write that kind of things in programming,

we do not signify, as is the case in mathematics,

that the relation "a = a + 1" must always be respected,

(in the context of mathematics, this particular expression may lead to problems)

In programming,

we simply signify that we are adding

1 to the value of a.

Now to the last chapter regarding variables :

the notion of constant.

We have seen that the assignment permits to modify

the value of a variable after its declaration.

There are situations, though, where this is not desirable.

Let us suppose that, in a program, we need to work

with the speed of light.

We all know that the speed of light is a constant.

Its value will thus not be modified over the course of the program.

Therefore, we will precise that this data cannot change.

In such a case, we proceed by adding the reserved

keyword "final" just before the variable declaration.

This means that, once an initial value has been attributed,

we cannot modify the value of the variable anymore.

Here, in this example, we declared our constant as follows :

the constant VITESSE_DE_LA_LUMIERE (TN:vitesse de la lumière means speed of light)

If, later on, we try to modify the value

through an assignment, this will result in a compiling error.