Constant is a quantity that will not be modified while the program is running.
Using the final keyword in Java to modify constant declarations is similar to variables
finaldouble PI =3.1415927;
Although constant names can also be in lowercase, capital letters are usually used to represent constants for ease of identification.
Literals can be assigned to variables of any built-in type. For example
byte a =68; char a ='A'
Byte, int, long, and short can all be represented in decimal, hexadecimal and octal.
When using constants, the prefix 0 represents octal and the prefix 0x represents hexadecimal. For example
intdecimal=100; int octal =0144; int hexa =0x64;
Like other languages, Java's string constants are also character sequences contained between two quotation marks. The following is an example of a string literal
"Hello World" "twonlines" ""This is in quotes""
Both string constants and character constants can contain any Unicode characters. For example
char a ='u0001'; String a ="u0001";
Java language supports some special escape character sequences.