Java uses the keyword final
to indicate ‘variables’ which
can only be assigned to once (usually where they are
declared). C uses the keyword const
with an
object declaration to indicate a constant object that can
(and must) be initialised, but cannot subsequently be
assigned to — it is not a variable, but it still has an
address and a size, so you can write &obj
or sizeof obj
.
double sin(double); /* mathematical function sine */ const double pi = 3.14159; double val; val = sin(pi); /* legal expression */ pi = 3.0; /* illegal; not a modifiable lvalue */