Constants :- Constants in java are fixed values those are not changed during the Execution of program java supports several types of Constants those are
1) Integer Constants:- Integer Constants refers to a Sequence of digits which Includes only negative or positive Values and many other things those are as follows
An Integer Constant must have at Least one Digit
it must not have a Decimal value
it could be either positive or Negative
if no sign is Specified then it should be treated as Positive
No Spaces and Commas are allowed in Name
2) Real Constants :-
A Real Constant must have at Least one Digit
it must have a Decimal value
it could be either positive or Negative
if no sign is Specified then it should be treated as Positive
No Spaces and Commas are allowed in Name
Like 251, 234.890 etc are Real Constants
In The Exponential Form of Representation the Real Constant is Represented in the two Parts The part before appearing e is called mantissa whereas the part following e is called Exponent.
In Real Constant The Mantissa and Exponent Part should be Separated by letter e
The Mantissa Part have may have either positive or Negative Sign
Default Sign is Positive
Single Character Constants:-
A Character is Single Alphabet a single digit or a Single Symbol that is enclosed within Single inverted commas.
Like ‘S’ ,’1’ etc are Single Character Constants
String Constants:- String is a Sequence of Characters Enclosed between double Quotes These Characters may be digits ,Alphabets Like “Hello” , “1234” etc.
Backslash Character Constants:- Java Also Supports Backslash Constants those are used in output methods For Example \n is used for new line Character These are also Called as escape Sequence or backslash character Constants For Ex: