0 votes
in JAVA by
What are the advantages of passing this into a method instead of the current class object itself?

1 Answer

0 votes
by

As we know, that this refers to the current class object, therefore, it must be similar to the current class object. However, there can be two main advantages of passing this into a method instead of the current class object.

this is a final variable. Therefore, this cannot be assigned to any new value whereas the current class object might not be final and can be changed.

this can be used in the synchronized block.

Related questions

0 votes
asked Oct 9, 2020 in JAVA by SakshiSharma
0 votes
asked Oct 17, 2020 in JAVA by rahuljain1
...