A constant is a value that will not change during the execution of your program
You use the keyword <<final>> with the data type that your constant belongs to:
For example, you can define a constant of type integer like so:
final int MY_CONSTANT=some_value;
You need to initialize a constant inline, which means that you have to give it a value right then and there;
You cannot reassign a value to a constant after it has been declared;
A constant can only hold a 'constant value' or expression that 'evaluates' to a constant value
For instance the number 2 is a constant. Adding another value, 3, to it will also result in a constant (since 3 is also a constant)! Also adding or assigning other constant types to your constant will also yield, you guessed it, a constant ;)
final int const1 = 3
final int const2 = 2+3;
final int const3 = const1+const3;// this works because const1 and const2 are constants
If you declare a non-constant, in other words, a variable, like so:
int variable = Obj.getSomeData(); // get some imaginary data
final int const4 = variable+5; // this will not work
Although 5 is a constant, adding it to a 'non-constant' will give you a non-constant and java will not compile this.
How many times have i used the word 'constant'? LOL!