Reputation: 135
I know that for example '5'
is literal of type char
but is 5 * 5
a literal? This is expression, however it has fixed value.
Upvotes: 5
Views: 143
Reputation: 1277
I'm not sure, but doesnt that terms work something like that?
var num =5; var stringLabel = "someText";
etc.
var result = 5*5; var res2 = a*x;
But of course- in result that also constant si it also can be literal in fact ..
That's how get it at least me..
It's just about terms- also like in java there are methods, "C languages" are functions, etc. - in meanings its also the same things, so it depends just on the limit what will you tolerate at all :D
Upvotes: 0
Reputation: 200168
"Literal" is a grammatical term, not semantical. It is the basic building block that denotes a constant value.
Although by specification 5 * 5
and 25
mean exactly the same, grammatically the first one is a binary expression involving two literals and an operator, and the second one is just a literal.
Upvotes: 1
Reputation: 100239
As described in Java Language Specification §15.28, it's a particular case of expression called "compile-time constant expression". It's not a literal.
Upvotes: 12
Reputation: 134
I don't think you can call it a literal. It's possible that some compilers will treat it the same way they deal with a literal, see the comment about which language you are using.
Upvotes: 1