CVMBF - Constant Variables Must Be Final
Local variables that never get their values changed must
be declared final
. By explicitly declaring them in such a
way, a reader of the source code get some information of
how the variable is supposed to be used.
Wrong
int var1 = 10;
int var2 = 20;
var1 = var2;
System.out.println(attr1);
}
Tip: Make all variables
which are never changed final
.
Right
int var1 = 10;
final int var2 = 20;
var1 = var2;
System.out.println(attr1);
}