Constants in JAVA programming Hands on coding

 What is constants in Java ?

  • Constant is an element of the program, whose value can not be changed during execution of program. 

  • Constants can also called as 'literals.'

  • Constant may be int, float and character data type.


Rules for constructing integer constant.


  1. It should contain atleast one digit.
  2. It should not have even single decimal point.
  3. Constant may be positive or negative.
  4. Comma and blank spaces are not allowed in integer constant.

Rules for constructing floating point constant.

  1. It must contain atleast single digit.
  2. It must have single decimal point.
  3. This may be positive or negative.
  4. Comma and blank spaces are not allowed in integer constant.

Rules for constructing character constant. 


  1. Constant may be a single alphabet, or digit or special a symbol.
  2. The length of the character constant is 1.
  3. Character constant can be enclosed within the single quotes (Example char c='A');

This is regarding the constants in java.

 For Videos Join Our Youtube Channel: Join Now

Thank you!