final keyword

#2
Very Good Question Indeed. Surprised to not to see the answer of this.

For this we will take an example of a setter method. Please see the same below:

Code:
public void setTest(String test) {
    test = test;
}
Now suppose i forgot to add the "This" keyword over here. What will happen here is the variable that you are trying to set here will not be set. Now if i Add the final keyword on the parameter. This would give me a compile time error and I will get to know that there is something wrong here. Which helps in understanding. Hope it helps.
 
#3
The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be:

1. variable
2. method
3. class.
 
Top