http://javarevisited.blogspot.sg/2011/12/final-variable-method-class-java.html
Sometimes I can't open this page without proper proxy configuration, so I have to copy the content here.
What is final keyword in Java?
Final is a keyword or reserved word in java and can be applied to member variables, methods, class and local variables in Java. Once you make a reference final you are not allowed to change that reference and compiler will verify this and raise compilation error if you try to re-initialized final variables in java.
What is final variable in Java?
Final variables are often declare with static keyword in java and treated as constant.
Final variables are by default read-only.
What is final method in Java
A java method with final keyword is called final method and it can not be overridden in sub-class.
You should make a method final in java if you think it’s complete and its behavior should remain constant in sub-classes.
Final methods are faster than non-final methods because they are not required to be resolved during run-time and they are bonded on compile time.
What is final Class in Java
Final class is complete in nature and can not be sub-classed or inherited. Several classes in Java are final e.g. String, Integer and other wrapper classes.
Benefits of final keyword in Java
1. Final keyword improves performance. Not just JVM can cache final variable but also application can cache frequently use final variables.
2. Final variables are safe to share in multi-threading environment without additional synchronization overhead.
3. Final keyword allows JVM to optimized method, variable or class.
Important points on final in Java
1. Final member variable must be initialized at the time of declaration or inside constructor, failure to do so will result in compilation error.
2. Local final variable must be initializing during declaration.
3.Only final variable is accessible inside anonymous class in Java.
4.All variable declared inside java interface are implicitly final.
5.Final and abstract are two opposite keyword and a final class can not be abstract in java.
6.Final methods are bonded during compile time also called static binding.
7.As per Java code convention final variables are treated as constant and written in all Caps. e.g.
private final int COUNT=10;
8.Making a collection reference variable final means only reference can not be changed but you can add, remove or change object inside collection. For example:<span style="font-size:14px;">private final List Loans = new ArrayList(); list.add(“home loan”); //valid list.add("personal loan"); //valid loans = new Vector(); //not valid</span>
In Summary whenever possible start using final in java it would result in better and faster code.