If you don't want others (or yourself) to overwrite existing values, you can add the const
keyword in front of the variable type.
This will declare the variable as "constant", which means unchangeable and read-only:
The const
keyword is useful when you want a variable to always store the same value, so that others (or yourself) won't mess up your code. An example that is often referred to as a constant, is PI (3.14159...).
Note: You cannot declare a constant variable without assigning the value. If you do, an error will occur: A const field requires a value to be provided.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!