Tuesday, August 18, 2020

6.1.1 Constant Literals

  • Constant literals are values that you use directly in the program. 
  • For example, look at the given code below.
y = x+2;

  • In the above given statement 2 is a constant literal. 
  • It has been directly used in the program. 
  • It can not be changed during the execution of the program.
  • Consider Constant literals such as direct values that can not be changed. 
  • Normally the use of literal constants is not advised.
  • Suppose you have used a literal constant in many places in the program, now if you need to change this constant, then you need to manually find it and change it all in the program.
  • Therefore, you should minimize the use of literal constants.

No comments:

Post a Comment

Please do not any spam link in Comment Box