Lets say I have a superclass Test1
public class Test1{
public int foo;
public void bar(final Integer value){
foo = 0;
}
}
And the subclass Test2
public class Test2 extends Test1{
public void bar(final Integer value){
foo = value;
}
}
1) What does final
in the class Test2
mean? And what does declaring a parameter final do and what would be the purpose?
Does this only mean, that the parameter can not change within the method?
2) If I call the method bar which was overwritten in Test2
, does it only change the inheritated field foo
of Test1
or would this change the the fields in of Test2
as well as Test1
?