As Sebastian Janisch has already said, the final modifier on the parameter means the parameter may not be re-assigned in that method. It is probably a good idea to make parameters final, but it doesn't appear to be obvious from the documentation comments whether a parameter is final or not.
Joined: Aug 11, 2009
Okay, thanks to you both.
So it would be fair to say the first one could be called as follows:
Foo myFoo = new Foo();
but, the second one could only be called like this?
static int x = 5;
static int y = 6
when you apply a non access modifier for a method then it holds for the method and not to its parameters. When you give a static to a method means its a static member of the class therefore implying that it doesn't need an instance of the class to access it. But the arguments passed can be anything. When you say final means its the end....in java terms that particular variable once assigned cannot be reassigned and for a method it cannot be overriden. In a method if it has a final parameter means the variable which is passed as argument to the parameter cannot be changed.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Joined: Oct 13, 2005
Nitish Bangera wrote: . . . When you say final means its the end....in java terms . . .
. . . and "final" about a class means it cannot be inherited from.
I misunderstood on being able to pass non-static variables to a static method. The HF book says "A static method can't access a non-static variable" and I guess I took that to mean you couldn't pass one either. This makes more sense and I appreciate the clarification.