字面量是你临时给定的 一个没有任何引用的值(包括基本数据类型和字符串)

常量是一个带引用的不可更改的值 你可以在程序的任何地方(当然只要是可访问到的地方)引用它

字面量不行 在你出现字面量的改行语句结束以后 这个字面量就无法被再次使用了

 

In programming, a value written exactly as it’s meant to be interpreted. In contrast, a variable is a name that can represent different values during the execution of the program. And a constant is a name that represents the same value throughout a program. But a literal is not a name — it is the value itself.
A literal can be a number, a character, or a string. For example, in the expression,
x = 3
x is a variable, and 3 is a literal.
—————————————————————————————————————————————————————
维基百科的解释是:In computer science, a literal is a notation for representing a fixed value in source code.
字面量就是用来描述源代码中固定值的表示法。
x = 3; //x是变量,3这个值就是字面量。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-09-03
  • 2022-12-23
猜你喜欢
  • 2021-07-12
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-01-21
相关资源
相似解决方案