Constants are values that are used directly within your program. There are several different types of constants
including:- BOOLEAN, INTEGER, LONG, FLOAT, DOUBLE and STRING.
BOOLEAN - BOOLEAN constants are simply the values TRUE and FALSE - they have no numeric value.
INTEGER - An Integer constant can be any whole number between -2147483648 and 21474836471 inclusive.
If your whole number is outside this range then you will have to define it as a LONG constant.
Example: 1, 15, 0x01234567 are all examples of Integer Constants.
LONG - A Long constant can be any whole number between -9223372036854775808 and 9223372036854775807 inclusive.
Long constants are identified by a trailing ‘L’ character. Thus 1L, 15L, 0x0123456789L are all examples of Long Constants.
FLOAT - A Float is a constant that contains a fractional elements. Float values are similar to Double values however
double values store values to a greater degree of accuracy. Float constants are identified by a trailing “F” or
“f” character. Thus 3.142F, 1.0F and -34.5E+1F are all examples for Float Constants
DOUBLE - A Double is a constant that contains a fractional elements. Double values are similar to Float values however
double values store values to a greater degree of accuracy. Floating point values not ending with a trailing “F” or
“f” are automatically regarded as double values. Double values can also explicitly be identified by a trailing “D” or
“d” character. Thus 3.142, 3.142D and -34.5E+1D are all examples of Double Precision Constants.
STRING - A String constant is a string of characters enclosed within double quotes. “Hello World” is an examples of String Constants
Print out some constants
This example consists of a series of statements that prints out the values of several constants:- true is a boolean constant,
34 is an integer constant, 100L is a long constant 3.142F is a single precision floating point constant, 31.42E-1D is a
double precision floating point constant and "Hello" is a string constant.