Please help me understand the difference between constant variables and final variables in Java. I am a bit confused with it.
Make variable "final" means we cannot reassign a value to this variable (ie we can use variable = Something once and only once.
So for primitive we can say final variable are constante.
But final variable can be non constant. for exemple
final Stringbuffer string = new StringBuffer("not");
string.append(" constant");
System.out.println(string);
will print the string "not constant". Here "string" variable is final but not constant. i hope this will help