Skip to main content

Special keywords in Java

"Final" keyword
http://renaud.waldura.com/doc/java/final-keyword.shtml
http://www.javamex.com/tutorials/synchronization_final.shtml


Note that storing a reference to an object in a final field only makes
the reference immutable, not the actual object

public final List<String> myList = new  ArrayList<String>( );

you can still modify "myList" as follows.

myList.add("good");

But the following code is not possible

myList = new ArrayList<String>( );
myList = some other list;
 


"Volatile" keyword
http://javarevisited.blogspot.com/2011/06/volatile-keyword-java-example-tutorial.html
http://www.javabeat.net/tips/169-volatile-keyword-in-java.html
http://www.javamex.com/tutorials/synchronization_volatile.shtml

Comments