Wednesday, September 20, 2006

Parameters as Final

You can declare parameters as final. Declaring parameters as final does not affect method overriding.

For example, method1(final int x, final int y) means the parameters x and y are constant throughout the method.

Final parameters have no impact on variables passed to methods. Because arguments are passed by value, changing them in a method would not have affected the original values in any case. But final arguments cannot be changed within the method.

No comments: