class T {}
interface Interface{
void method(final T t);
}
class FirstClass implements Interface{
public void method(T t){
//valid
}
public void method2(final T t){
}
}
class SecondClass extends FirstClass {
public void method2(T t){
//valid
}
}
In the above code, why it is not considering the final qualifier while overriding a method?
My understanding of final qualifier in method signature is, the method will not allow to change the reference. But I don't understand what is the use of it?
Lets say I'm using 3rd party jar, and I'm concern about that 3rd party jar should not change my object while it processing, the code should be like this,
3rdPartyClass.doProcess((final) myObject);
class 3rPartyClss {
public void doProcess(SomeClass myObject){}
}
but why its like
3rdPartyClass.doProcess(myObject);
class 3rPartyClss {
public void doProcess(final SomeClass myObject){}
}
If the 3rd party knows he is not going to change the object reference inside the method, then what is the use of having final in signature? In overriding method also it will not consider the final qualifier. Then what is the real use of it?
I found similar question like this here, but want more clarification on this