Answer the question
In order to leave comments, you need to log in
How to learn to determine what is an operand and what is a literal, and are they the same in all languages?
As I understood from google and other answers, a literal is a literal representation of an object, i.e. a literal is an object first and foremost and is stored in memory. And the operand is what the operation is applied to.
And I imagine for myself that literals are some part, for example, if you write String [] array = {1,2,3};
then here String is a type, [] is an array object literal, array is a variable name consisting of ascii characters, = is an assignment operator, {} are two object literals, 1, 2, 3 is an operand and at the same time a number literal.
But in this example:
array[1] - array is already an operand and 1 is also an operand, and [] is an operation.
And signs like , . ""''\|{}; do they have a generic name?
And if we take this example class Person{ String name;
Here class is a keyword, Person is the name of the object, {String name; int age} - object literal, name and age - variable names, String, int - type, { } - literal.
But what if there are just abcde characters in the code that seem to be not a string, since they are not wrapped in quotes, or < > - + = operators, while they are presented in the development environment? Just a set of ascii characters? And are they stored in memory?
Answer the question
In order to leave comments, you need to log in
why define?
i.e. in general? what will this knowledge give?
Plus, it works differently for different languages.
A literal is the value of a variable explicitly written in the code, i.e.
x = 1
obj = { a: "1"}
1
and are literals.
The operand is what the operation is applied to, i.e. is an addition operation, and are operands, moreover , it is also a literal at the same time. { a: "1"}
y = x + 1
+
x
1
1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question