We have a method whose parameter is defined as final,and then change the value of this parameter(in this method) and return it, it should not be changed as we passed it as final.
But this is not the case.
Please help me to understand this!
public static void main(String[] args) {
EmployeeBean e1 = new EmployeeBean("1", "jitu");
System.out.println("object before set >>" + e1.getEmpName());
EmployeeBean newObj = x.changeFinalvalue(e1);
System.out.println("object after set >>" + newObj.getEmpName());
public EmployeeBean changeFinalvalue(final EmployeeBean x) {
x.setEmpName("Jeet");
return x;
}
Output : object after set >>jitu
object after set >>Jeet //doubt:it has to be 'jitu' only