This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by ashok_kumar: i want to have final array i.e the elements in that array should be final is it possible
I hope it clarifies: a) You can declare array containing only final elements. b) You can't force the array to contain only final elements (eg as function's parameter) c) You can't force array to disable changing it's elements by arr[idx] = val
To get to grips with this, remember that an array is an instance of the class Array. So if you declare "final int = new int;" what you're really doing is creating a final instance of class Array. As you know you can change the instance members of a final Object instance but not the reference to the Object, therefore you can change the content of a final array but not assign a different array to it.