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.
- It should contain atleast one digit.
- It should not have even single decimal point.
- Constant may be positive or negative.
- Comma and blank spaces are not allowed in integer constant.
Rules for constructing floating point constant.
- It must contain atleast single digit.
- It must have single decimal point.
- This may be positive or negative.
- Comma and blank spaces are not allowed in integer constant.
Rules for constructing character constant.
- Constant may be a single alphabet, or digit or special a symbol.
- The length of the character constant is 1.
- 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!