What is constants in Java ?
What is constants in Java ?
- An element of program whose value can not be changed at the time of execution of program is called constant.
- It is also called literals.
- It may be int,float and character data type.
Rules for constructing integer constant
- It must have atleast one digit.
- It must not have a decimal point.
- It may be positive or negative.
- No comma or blank space are allowed in integer constant.
Rules for constructing floating point constant
- It must have atleast one digit.
- It must have a decimal point.
- It may be positive or negative.
- No comma or blank space are allowed in floating point constant.
Rules for constructing character constant
- It is a single alphabet,digit or special symbol.
- The length of character constant is 1 character.
- Character constant is enclosed within single quotes (Example char c='A';).