Ioanna Katsanou wrote:I understood that literal represent "constant values"
Yes. That's a very good way of thinking about it. But more precisely, they are constant values which are recognized by the compiler as such
because they are expressed in special formats. So that includes numeric literals,
string literals, boolean literals, character literals, and the null literal. (I think that's all... there might be something I've missed but
you should get the idea from that list.)
So no, variable names are not literals, even though you might be able to analyze the code and decide that the value of the variable cannot change. Likewise computed expressions like
8/2 and
"ice-" + "cream" are not literals, even though their result is a constant value.