Why is the "this" keyword final in Java? -
this question has reply here:
why assignment 'this' not allowed in java? 6 answersit seems thing no 1 has realized, "this reference" in java final. in normal programming day thought redefine entire instance redefining reference within own class:
public void method() { = new myobject("arg1", arg2, arg3); //it throws compile error } why reference final in java?
the problem not this final reference - it's not reference @ all. this keyword "denotes value reference object instance method or default method invoked" (jls §15.8.3).
furthermore, wouldn't create sense reassign in sense variable can reassigned. remember reassigning reference changes reference, , not other references might point same object. reassigning this not insane useless.
java final
No comments:
Post a Comment