java - Why can we use 'this' as an instance method parameter? -
what receiver parameter in java ? java 8 language specification talks this.
the jls gives a hint:
either way, receiver parameter exists solely allow type of represented object denoted in source code, type may annotated.
these 2 methods equivalent:
class test { void m1() { } void m2(test this) { } } however latter allows add together annotations:
void m2(@myannotation test this) { } //where myannotation can defined example: @target(elementtype.type_use) @interface myannotation {} java parameters java-8 this
No comments:
Post a Comment