Javatpoint Logo
Javatpoint Logo

Const keyword

  • Constants are one type of variable which we can define for any class with keyword const.
  • Value of these variables cannot be changed any how after assigning.
  • Class constants are different than normal variables, as we do not need $ to declare the class constants.
  • If we are inside the class then values of the constants can be get using self keyword, but accessing the value outside the class you have to use Scope Resolution Operator.

Example 1

Output:

Const keyword

Example 2

Output:

Const keyword
Next Topic




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA