Lig*_*ica 37
文字是直接在代码中呈现的一些数据,而不是通过变量或函数调用间接呈现.
以下是一些示例,每行一个:
42
128
3.1415
'a'
"hello world"
Run Code Online (Sandbox Code Playgroud)
构成文字的数据不能由程序修改,但可以将其复制到变量中以供进一步使用:
int a = 42; // creates variable `a` with the same value as the literal `42`
Run Code Online (Sandbox Code Playgroud)
术语"文字"来自于这样一个事实,即您已经将数据字面地写入程序中,即完全按照书面编写,而不是隐藏在变量名称后面.