Solidity provides usage of literal for assignments to variables. Literals do not have names; they are the values themselves. Variables can change their values during a program execution, but a literal remains the same value throughout. Take a look at the following examples of various literals:
- Examples of integer literal are 1, 10, 1,000, -1, and -100.
- Examples of string literals are "Ritesh" and 'Modi'. String literals can be in single or double quotes.
- Examples of address literals are 0xca35b7d915458ef540ade6068dfe2f44e8fa733c and 0x1111111111111111111111111111111111111111.
- Hexadecimal literals are prefixed with the hex keyword. An example of hexadecimal literals is hex"1A2B3F".
- Solidity supports decimal literals with use of dot. Examples include 4.5 and 0.2.